I have a div with position:absolute, left:0, right:0; widht:100%. This is fine with my code.
But when i have added another div, which it has width:2000px; my first div width is not expanding. Can you please suggest me.
This is my example. http://jsfiddle.net/vYhv4/
Thanks
The
position:absoluteproperty positions the element relative to its ancestor element, in your case that is thebodyof the document, which is not the width of your.displayElementclass. One thing you can do to fix this is to contain both your.displayElementclass and your absolutely positioned div,.box, inside of a container that is clearfixed that acts as the ancestor of your.boxdiv, positioned relative.Like so:
HTML
CSS
Demo