css - 1 image and two elements floating right next to it -
i trying have 1 image , 2 elements floating right next (and 2 elements on 2 separate lines). tried working display:inline-block each of 2 elements comes on separate line, no luck. also, "brand" should on top of "model", first mercedes , second w126. possible achieve this?
fiddle here... fiddle
html:
<div class="car"><img alt="" src= "http://placehold.it/50x50&text=car"></div> <div class="brand"> mercedes </div> <div class="model"> w126 </div> css:
.car img { max-width:100%; max-height:100%; margin:0; display:block; } .brand { font-size:16px; color:#333333; font-family:'droid serif'; font-weight:bold; padding-left:10px; padding-bottom:0px; padding-top:5px; float:left; margin-left:2px; margin-right:2px; margin-top:2px; display:inline-block; } .model { font-size:12px; color:#5a5a5a; font-family:'droid serif'; font-style:normal; margin-left:2px; margin-right:2px; margin-bottom:2px; padding-left:10px; float:left; display:inline-block; }
you can use floats instead:
.car img { max-width:100%; max-height:100%; margin:0; float:left; } .brand { font-size:16px; color:#333333; font-family:'droid serif'; font-weight:bold; padding-left:10px; padding-bottom:0px; padding-top:5px; margin-left:52px; margin-right:2px; margin-top:2px; } .model { font-size:12px; color:#5a5a5a; font-family:'droid serif'; font-style:normal; margin-left:2px; margin-right:2px; margin-bottom:2px; padding-left:10px; float:left; } <div class="car"> <img alt="" src="http://placehold.it/50x50&text=car"> </div> <div class="brand">mercedes</div> <div class="model">w126</div> note .brand has no float allows w126 pushed line below it, , margin has been increased space properly.
Comments
Post a Comment