css - Floating divs around and under an image -
i trying design page floating image left, div right text , block elements flowing around image, , more div's below image. see http://jsfiddle.net/bcjzk/3/ code:
.container { width:700px; border:solid 1px gray; } .content { width:460px; border:solid 1px red; margin-right:0px; margin-left:auto; } .extra-content { width:230px; border:solid 1px green; } img { float:left; border:solid 1px blue; } blockquote { border:solid 1px gray; width:30%; float:right; }
and
<div class="container"> <img src="http://hazelden.ca/sample.png" width="320" height="auto" /> <div class="content"> <p> content, blockquotes , images</p> </div> <div class="extra-content"> more text </div> </div>
the large image set specific width, height set @ "auto".
i can't green-bordered div (class="extra-content") nestle in space directly under large image , still have text , block elements in red-bordered div (class="content") flow properly. i've tried multiple combinations of clear: in various elements , re-ordering div's.
i'm hoping it's simple i'm not seeing.
i got working in fiddle:
because of way div layouts work, going start green div below red 1 if comes after red 1 in html code unless put in parent container encapsules entire left side.
as fix made container div hold both img , green div , floated container left.
html:
<div class="container"> <div class="imgcontainer"> <img src="http://hazelden.ca/sample.png" alt="some image" width="320" height="auto" /> <div class="extra-content"> text </div> </div> <div class="content"> ...
css:
.container { width:700px; border:solid 1px gray; } .imgcontainer{ float: left; } .content { width:460px; border:solid 1px red; margin-right:0px; margin-left:auto; } .extra-content { width:230px; border:solid 1px green; } img { border:solid 1px blue; } blockquote { border:solid 1px gray; width:30%; float:right; }
edit:
i noticed imgcontainer box forces content text change position accommodate it's presence. if want content text lay out precisely same before use this:
.imgcontainer{ float: left; height: 450px; overflow: visible; }
you can content text under pic close on side changing height property of imgcontainer 430px.
hope helps!
Comments
Post a Comment