javascript - Image is getting pushed outside of the div its wrapped in -
nobel prize person can figure out why second image pushed outside div wrapped in.
i thought did pretty straightforward:
<div class="outerdiv" id="headerbox"> <div id="uwlogo"> <img src="uwlogo.png" height="50px"\> </div> <div id="jaminweb"> <h1>jaminweb</h1> </div> <div id="rainer"> <img src="rainer.jpg" height="50px"\> </div> </div>
with corresponding stylesheet code
#uwlogo { float: left; } #jaminweb { float: center; } #rainer { float: right; } h1 { color: #fff; font-weight: 400; text-align: center; margin: auto; padding: auto; }
jfiddle link, since know request one: http://jsfiddle.net/u7pjj/
to answer why it's happening number of things:
- float: center not valid it's not floating
- your #jaminweb taking 100% width forcing third floating (rainer) element wrap , float right (on next line)
- your headerbox set height of 50px , float not change dimensions, appears floating outside of container.
to fix suggest going absolute positioning instead of floating. way jaimenweb div can centered , take full width , logos placed around it.
#headerbox { width: 80%; height: 50px; position: relative; } #uwlogo { position: absolute; left: 5px; top: 5px; } #jaminweb { text-align: center; } #rainer { position: absolute; right: 5px; top: 5px; }
i've updated fiddle: http://jsfiddle.net/u7pjj/1/
Comments
Post a Comment