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:

http://jsfiddle.net/bcjzk/4/

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;     } 

http://jsfiddle.net/bcjzk/5/

you can content text under pic close on side changing height property of imgcontainer 430px.

http://jsfiddle.net/bcjzk/6/

hope helps!


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -