css - Positioning a section next to figure -
i have sections in aritcle. , figures in same article. have 3 sections , 3 figures. want align section , figure side side alternatively. example,
#aricle# #section# #figure # #figure # #section# #end
so far tried floating figure... figure appears on top of section. want both of them seperated side side. heres html
<article> <section id="about"> <header>about me</header> <p> text </p> </section> <figure> <img src="css/images/body2.jpg" height="200" width="300" /> <figcaption>an image</figcaption> </figure> </article>
my section have different background, figure contain different image. body have different background well. heres css
section { background-image: url("images/paper.png"); padding-right: 20px; padding-left: 20px; } figure { margin-right: 15px; float: left; }
when try float image, appears on top of section background. want them separated. how achieve this? thank you. edit** please avoid divs. thank you
instead of using float
use display:inline-block;
& width:40%
both section & figure display side side.
section { background-image: url("images/paper.png"); } section,figure { display:inline-block; width:40%; padding-right: 20px; padding-left: 20px; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
<article> <section id="about"> <header>about me</header> <p> text </p> </section> <figure> <img src="css/images/body2.jpg" height="200" width="300" /> <figcaption>an image</figcaption> </figure> <figure> <img src="css/images/body2.jpg" height="200" width="300" /> <figcaption>an image</figcaption> </figure> <section id="about"> <header>about me</header> <p> text </p> </section> <section id="about"> <header>about me</header> <p> text </p> </section> <figure> <img src="css/images/body2.jpg" height="200" width="300" /> <figcaption>an image</figcaption> </figure> </article>
Comments
Post a Comment