html - Text centered next to image, and if no space, aligned to top -


let's check this fiddle:

img {     float: left; }  #inner {     height: 128px;      background-color: yellowgreen;      display: table-cell;     vertical-align: middle; }  #content {     background-color: red; }  <img src="http://cdn.memegenerator.net/instances/250x250/37934290.jpg" width="128" height="128" /> <div id="inner">     <div id="content">text text tertkl elknr tlken lsl kdmfsldkfmsldkfmslkd mfkndfln dflkfndg lkn</div> </div> 

this works far expect - text centered, , shrink width, text goes underline: "too far" image. best if vertical-align: middle; became vertical-align: top; when needs jump. how without possibly jquery?

a simple way achieve use css media query.

your markup stay same , css need have following added:

@media screen , (max-width: 290px) {     #inner {         vertical-align: top;        } } 

in action: http://jsfiddle.net/uwmkh/1/

what says is, "when viewport's width no more 290px, stuff #inner.

take @ these links more information:

the caveat using media queries aren't supported in ie8 , below. hope don't have deal headaches!

look here complete list of browsers support:


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -