I have this div:
<div class="member">
<div class="memberImage"><img src="" /></div>
<div class="memberInfo">John Doe</div>
</div>
This is the css for it:
.member {
width:200px;
clear:both;
position:absolute;
padding:5px;
}
When I duplicate this div just beneath this one they appear to be one over the other because of the position:absolute
.
Is it possible to keep the position:absolute
and have them one below the other as normal?
Thanks,
Absolute Positioning You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document. Move Left - Use a negative value for left. Move Right - Use a positive value for left. Move Up - Use a negative value for top.
You would need to either use relative positioning on both, or absolute positioning for both and set their specific top and left values. Alternatively you could set a top margin on footer that makes it drop enough so it is positioned below the container. You also need to look at your css.
With a relative positioned parent element, an absolute positioned element has a boundary. And with the left , right , top and bottom properties with a value of 0 (specifying the distance of the edges), and an auto margin, the absolute element is centered in the parent element.
Is it possible to keep the position:absolute and have them one below the other as normal?
Simple answer: no.
Possible solutions:
top
attribute to the member class and increment for every memberJudging from your code snippet you want to create a memberlist. A simple pattern that would fit well for this is simply an UL
(Unordered list):
<ul class="memberlist">
<li>
<div class="memberImage"><img src="foo.jpg" /></div>
<div class="memberInfo">John Doe</div>
</li>
<li>
<div class="memberImage"><img src="foo.jpg" /></div>
<div class="memberInfo">John Doe</div>
</li>
<li>
<div class="memberImage"><img src="foo.jpg" /></div>
<div class="memberInfo">John Doe</div>
</li>
</ul>
And a corresponding CSS to go with it:
.memberlist li {
width: 200px;
padding: 5px;
margin-bottom: 10px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With