Forum Moderators: open

Message Too Old, No Replies

Dynamically calculate a div width

         

Rain_Lover

3:18 pm on Apr 29, 2011 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,

Here are sample divisions:

<style type="text/css">
#grandparent {width:100px;}
#parent {overflow:auto; height:100px; }
.child {overflow:hidden; margin-left:10px;}
</style>

<div id="grandparent">

<div id="parent">

<div class="child">1000000000000000000000000</div>
<div class="child">1000000000000000000000000</div>
<div class="child">1000000000000000000000000</div>
<div class="child">1000000000000000000000000</div>
<div class="child">1000000000000000000000000</div>
<div class="child">1000000000000000000000000</div>
<div class="child">1000000000000000000000000</div>

</div>

</div>


The <div class="child"> width value is always 10 pixels less than <div id="parent"> width value. How can it be calculated so any width value is given to <div id="parent">, its child gets 10 pixels less than that?

Any help is very much appreciated!
Mike

daveVk

3:25 am on May 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Provided you use style.width to change parents width I think the child width will always be 10px less (margin-left:10px), is this not the case ?

Rain_Lover

12:48 pm on May 2, 2011 (gmt 0)

10+ Year Member Top Contributors Of The Month



Please ignore the question as I found a simple solution to my problem.

Thanks all the same!