Issue
I have a position relative container and it's a lot of absolute position div. I want to calculate absolute div's height for the my relative container. How can i do this with css or jquery? I can't see container's red background...
<!DOCTYPE html>
<html>
<body>
<div id="container" style="position:relative;overflow:hidden;width:300px;background-color:red;">
<div style="position:absolute;top:0px;left:0px;width:100px;">
Lorem ipsum
</div>
<div style="position:absolute;top:0px;width:100px;left:100px;">
Lorem Ipsum
</div>
</div>
</body>
</html>
Solution
if the divs are all positioned horizontally (next to each other) and width no left or right margin (which by looking at your code I suppose the conditions are matched) then you could do this: http://jsfiddle.net/U6RXB/1/
var width=0;
$('#container').children('div').each(function(){
width=width+$(this).width();
});
$('#container').width(width);
if any of the conditions I mentioned are not matched with your code then notice me and I'll fix it again.
Answered By - Amin Jafari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.