CSS align text fixed beside float element

2014-06-16 22:56 by Thorben Bürgel

Today I covered a problem with my HTML and CSS layout.

I had a picture with CSS style float:left, which was followed by a textblock beside. The text was overflowing after the height of the picture, such that it continues underneath the picture. But I wanted the text to begin always at the same edge, according to the right edge of the image. After some searching and testing I found a solution and this is for the record:

Put your text inside a div container and give it the style attributes overflow:hidden and display:block, like this:

<div style="overflow: hidden; display: block;">Some text...</div>

Go back