How to avoid text go below the thumbnail with css -
How to avoid text go below the thumbnail with css -
i have posts list thumbnails.
i'm trying prevent title going under image.
i tried white-space: normal
didn't effect text here. tried float: left
, display:inline
nil helped maintain title beside image.
code css&html:
class="snippet-code-css lang-css prettyprint-override">ul{ list-style-type:none; padding:0; background-color:white; } li{ border: 1px solid gray; width: 325px; border-bottom:1px solid @border-color; padding:10px; white-space: normal; } img{ width:80px; height:80px; } .post-title{ display: inline-block; margin-left:5px; vertical-align: middle; } .post-title a{ white-space: normal; color:@breadcrumbs-current-color; } .post-title p{ margin-bottom:0; color:gray; font-size:11px; }
class="snippet-code-html lang-html prettyprint-override"><ul> <li> <a><img src="http://blog.room34.com/wp-content/uploads/underdog/logo.thumbnail.png"/ ></a> <div class="post-title"> <a>street dance moves comically illustrated <p>200 view</p> </a> </div> </li> <li> <a><img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png"/></a> <div class="post-title"> <a>hello world <p>80 view</p> </a> </div> </li> </ul>
one quick solution utilize max-width
, remove vertical-align
:
class="snippet-code-css lang-css prettyprint-override">ul { list-style-type: none; padding: 0; background-color: white; } li { border: 1px solid gray; width: 325px; border-bottom: 1px solid@border-color; padding: 10px; white-space: normal; } img { width: 80px; height: 80px; } .post-title { display: inline-block; margin-left: 5px; max-width: 200px; } .post-title { white-space: normal; color: @breadcrumbs-current-color; } .post-title p { margin-bottom: 0; color: gray; font-size: 11px; }
class="snippet-code-html lang-html prettyprint-override"><ul> <li> <a> <img src="http://blog.room34.com/wp-content/uploads/underdog/logo.thumbnail.png" /> </a> <div class="post-title"> <a>street dance moves comically illustrated <p>200 view</p> </a> </div> </li> <li> <a> <img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png" /> </a> <div class="post-title"> <a>hello world <p>80 view</p> </a> </div> </li> </ul>
but suggest go display: table
technique:
class="snippet-code-css lang-css prettyprint-override">ul { list-style-type: none; padding: 0; background-color: white; } li { display: table; border: 1px solid gray; width: 325px; border-bottom: 1px solid@border-color; padding: 10px; white-space: normal; } img { width: 80px; height: 80px; } .post-title { display: table-cell; margin-left: 5px; max-width: 200px; vertical-align: middle; } .post-title { white-space: normal; color: @breadcrumbs-current-color; } .post-title p { margin-bottom: 0; color: gray; font-size: 11px; } li > { width: 90px; display: table-cell; vertical-align: middle; }
class="snippet-code-html lang-html prettyprint-override"><ul> <li> <a> <img src="http://blog.room34.com/wp-content/uploads/underdog/logo.thumbnail.png" /> </a> <div class="post-title"> <a>street dance moves comically illustrated <p>200 view</p> </a> </div> </li> <li> <a> <img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png" /> </a> <div class="post-title"> <a>hello world <p>80 view</p> </a> </div> </li> <li> <a> <img src="http://www.ionnic.com/media/catalog/product/cache/1/thumbnail/80x80/9df78eab33525d08d6e5fb8d27136e95/b/e/becable.png" /> </a> <div class="post-title"> <a>hello world hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world <p>80 view</p> </a> </div> </li> </ul>
css text inline textwrapping
Comments
Post a Comment