Take a look at the following jsfiddle:
http://jsfiddle.net/tTNNm/
How can you put div.text
next to a section of an image without hard coding the width of the div.text
in CSS?
It is assumed that the div should be the full width of what it has, and then the height should be determined by how much of the content should be wrapped to the next line due to the width restrictions of this parent element. So, in my violin, how did it happen that div.text
occupies a full width of 300 pixels and forces itself to the next line instead of setting images with a calculated width of 200 pixels next to the div?
Link:
<div class="test"> <div> <img src="http://www.cadcourse.com/winston/Images/SoccerBall.jpg" width="100" height="100"/> </div> <div class='text'> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> </div>โ div.test { width: 300px; outline: 1px solid blue; height: 100px; } div.test div { float: left; outline: 1px solid red; }
source share