layout - CSS: Laying out child columns sticking to left & right border of parent element -



layout - CSS: Laying out child columns sticking to left & right border of parent element -

laying out kid columns leftmost , rightmost columns stick left , right border of parent container has been challenge me (image attached) , know right way (the way in experienced designer it) doing in css.

as in the link image, there 4 kid column . https://dl.dropboxusercontent.com/u/27899629/stack/treatment-block.png

the way coded it: css

#treatments-block { background-color: #faf1e2; min-height: 400px; } .treatment-row { margin-top: 10px; border: 1px solid red; overflow: auto; } .treatment { width: 17%; margin-right: 10%; float: left; } .treatment img { max-width: 100%; }

html

<div id="treatments-block"> <div class="centrewrap"> <div class="section-title light-brown-color">skin treatments available</div> <div class="treatment-row" style="margin-top:0"> <div class="treatment"> <img src="images/botox-fillers-thumb.jpg"> <h3>botox & fillers</h3> <p>some cool text in here cool text in here..</p> </div> <div class="treatment"> <img src="images/botox-fillers-thumb.jpg"> <h3>botox & fillers</h3> <p>some cool text in here cool text in here..</p> </div> <div class="treatment"> <img src="images/botox-fillers-thumb.jpg"> <h3>botox & fillers</h3> <p>some cool text in here cool text in here..</p> </div> <div class="treatment" style="margin-right:0;"> <img src="images/botox-fillers-thumb.jpg"> <h3>botox & fillers</h3> <p>some cool text in here cool text in here..</p> </div> </div> </div> </div>

to style lastly element of parent element, can utilize :last-child pseudo class. in illustration this:

css:

.treatment-row{margin-top:10px;border:1px solid red;overflow:auto;} .treatment{width:22%; margin-right: 4%; float:left;} .treatment img{max-width:100%} .treatment:last-child{float:right; margin-right: 0}

note: name "last-child" little missleading, because doesn't refer lastly kid of element, lastly kid of parent element. e.g.:

for list of lis in ul, need utilize li:last-child select lastly li in list

css layout

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -