html - Is it possible to bottom align images and top align a caption beneath them? -



html - Is it possible to bottom align images and top align a caption beneath them? -

i need arrange dynamic number of images in zurb foundation block grid , each image has caption of varying length.

i wondering if there way align so:

i have been able bottom align everything: jsfiddle

ul.block-grid li { display: inline-block; float: none; } ul.block-grid li img { vertical-align: baseline; width: 100%; max-width: 100%; }

but unable figure out how accomplish alignment like. have tried absolute positioning captions, lose width , height (and position in dom of course): jsfiddle

ul.block-grid li p.caption { position: absolute; }

any tips achieving alignment appreciated.

you can realize layout using css tables follows.

if html looks this:

<div class="row full-width"> <div class="columns small-12"> <ul class="block-grid small-block-grid-5"> <li> <a href="#"> <img src="http://placehold.it/300x400" /> <p class="caption">test caption</p> </a> </li> <li> <a href="#"> <img src="http://placehold.it/300x400" /> <p class="caption">a longer test caption...</p> </a> </li> ... </ul> </div> </div>

apply next css:

class="lang-css prettyprint-override">.row.full-width { width: 100%; margin-left: auto; margin-right: auto; max-width: initial; } ul.block-grid li { display: inline-table; float: none; } ul.block-grid li { } ul.block-grid li img { vertical-align: baseline; width: 100%; max-width: 100%; } ul.block-grid li p.caption { text-align: center; }

you have plenty semantic html plenty of elements work with.

within .block-grid containing block, set display: inline-table on li element.

you can set vertical-align value either baseline or bottom , adjust margins , padding on kid elements needed.

this css seems work zurb foundation classes.

see demo at: http://jsfiddle.net/audetwebdesign/h5rlg/

design comment: if have overly long caption, there big whitespace regions between 2 rows of items, add together max-height p.caption , enable vertical scrolling. alternatively, utilize javascript/jquery , have expandable panel "show more" button.

in firefox, resulting layout looks like:

html css zurb-foundation vertical-alignment

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -