Making div to drop down when div beneath it change it's height dimension ?

This is a discussion on "Making div to drop down when div beneath it change it's height dimension ?" within the Web Page Design section. This forum, and the thread "Making div to drop down when div beneath it change it's height dimension ? are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 15th, 2007, 17:25
New Member
Join Date: Oct 2007
Location: Belgrade
Age: 26
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Making div to drop down when div beneath it change it's height dimension ?

OK,I will try to be as clear as possible.
I have one div (container) 500pix height containing two another divs in it. One of them is 200 height and another one that is on bottom is 300. Now if I manually change dimension of div that is on bottom to 200 pix, I want the one that is on top to get down as much as it can (so it's 100pix in this case) to the top of the one div that is on the bottom.
So if you understand me I want to make the position of the div that is on the top to depends on the height dimension of the div that is on the bottom, and to always drop down to it so they touch each other.
I need this for some javascript programming...
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 15th, 2007, 22:04
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Making div to drop down when div beneath it change it's height dimension ?

Sounds like something that can be achieved using JavaScript. I personally don't know of any way of doing it but maybe there is
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 15th, 2007, 23:59
Reputable Member
Join Date: Sep 2007
Location: Tehran - Iran
Age: 29
Posts: 434
Blog Entries: 2
Thanks: 7
Thanked 7 Times in 7 Posts
Re: Making div to drop down when div beneath it change it's height dimension ?

you can achieve to this by javascript, here is the sample code i have created :

HTML: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">

</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#con {
    background-color: #CCCCCC;
    height: 600px;
}
#first {
    background-color: #666666;
}
#sec {
    background-color: #FFFF00;
    height: 200px;
}
-->
</style>
</head>

<body>

<div id="con">
  <div id="first">Here goes the first div contains</div>
  <div id="sec">Here goes the second div contains</div>
</div>
<script type="text/javascript">;
    //Get the container height
    conH = document.getElementById("con").offsetHeight;
    //Get the top div height
    firstH = document.getElementById("first").offsetHeight;
    //Get the bottom div height
    secH = document.getElementById("sec").offsetHeight;
    //Calculate the difference between container height and bottom height
    firstNewH = conH - secH;
    //Set the new height for the top div
    document.getElementById("first").style.height= firstNewH + "px";
</script>
</body>
</html>
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems making the content area have a dynamic height blizeH Web Page Design 41 Aug 13th, 2007 01:19
Will it slide beneath? marksk Web Page Design 7 Apr 26th, 2007 08:58
how do I change the height of an <input type="text"> box? MikeTheVike Web Page Design 1 Feb 23rd, 2007 22:23
Making A CSS horizontal, drop down menu Powderhound Web Page Design 15 Aug 22nd, 2006 10:42
Making sure the height of both divs is = csa Web Page Design 8 May 3rd, 2006 18:22


All times are GMT. The time now is 02:54.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42