CSS Vertical Alignment Of Div
I have a heading, then below that I display a selection of items next to each other. On the same line as the selection of items I display a single picture. The issue I'm having is
Solution 1:
If the image is a fixed size, a quick fix for this problem would simply be to use a negative margin-top, so that the image is its own height above - so bottom is actually where the top is now.
E.g. If the image is 130px height, do:
#single_image img { margin-top: -130px; }
Solution 2:
One potential solution is to wrap them in a container and absolutely position #items to the bottom of the container. Here is a sample:
<div class="container">
<h1>H1 Title</h1>
<div id="items">
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</div>
<div id="single_image">
<img src="myImage.png" />
</div>
<div class="clearfix"></div>
</div>
CSS:
#items { float:left; }
#items ul { list-style:none; margin:0; padding:0; position: absolute; bottom: 0; }
#items ul li { float:left; margin-right:20px; font-size:22px; width: 50px; background: #DDD; }
#single_image { }
#single_image img { float:right; height:130px; width:inherit; background: #DDD; }
.container { width: 50%; margin: 0 auto; background: #EEE; position: relative; }
.clearfix { clear: both; }
Post a Comment for "CSS Vertical Alignment Of Div"