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 }
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
Post a Comment