css - Adjust automatically the size of div -


i have code, .text not working expected. auto should fit in width of container, .text div pushed second line. need auto value because width of image can change, , right div should fit in container regardless of image width.

<div class="container">     <div class="img"><img src="http://placehold.it/350x150"></div>     <div class="text">some text textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text</div> </div>  .img, .text {     float:left; }  .text{     border: 1px solid red;     height:150px;     width:auto; //should width:248px in specific case; }  .container{     width:600px;     border:1px solid green;     height:150px } 

http://jsfiddle.net/lcakw/

just don’t let .text class float well. way block element, taking full width (of parent element) minus floating. might want apply left padding though.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -