Aligning images in a row with text below each image
Set a width on the .member
elements, and float
them.
jsFiddle example - it works responsively.
Notice, as pointed out in the comments, this also aligns the text at the bottom if the images are of differing demensions.
Updated CSS
#design-cast {
position: relative;
overflow: hidden;
}
.member {
float: left;
width: 31%;
margin: 1% 1% 45px 1%;
}
.name {
position: absolute;
bottom: 0px;
}
.member img {
width: 100%;
display: block;
}
secondubly
Updated on June 05, 2022Comments
-
secondubly almost 2 years
In short, I'm trying to achieve a design similar to this:
Where the white boxes are images, and the red brushes are lines of text (the top line would hold a name and underneath their specialty) but using divs has proven to be problematic as I can't get the content to line up in a proper row - I'm not too keen on using a table for something like this due to compatibility problems, so I'm hoping someone on here would be able to assist me in trying to get it to work with divs before I fall back to that.
Below is the code I have so far and a jsfiddle accompaniment.
<div id="design-cast"> <h4>Design</h4> <div class="member"> <img src="http://i.imgur.com/OBUL7se.jpg" class="img-responsive img-thumbnail" alt="Responsive image" /> <div class="name">Name <br />Description</div> </div> <div class="member"> <img src="http://i.imgur.com/OBUL7se.jpg" class="img-responsive img-thumbnail" alt="Responsive image" /> <div class="name">Name <br />Description</div> </div> <div class="member"> <img src="http://i.imgur.com/zmPeyso.png" class="img-responsive img-thumbnail" alt="Responsive image" /> <div class="name">Name <br />Description</div> </div> </div>
CSS
.member { display: inline; } .name { display: inline; } .member img { width: 13%; display: block; }