Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Need css to evenly distribute pics w/text.

Have 8 profile pics w/text, each in a .box element. 280px x 750px. All are within a .container element. Need css to align 4 on 4? cant figure out the order of clear: float of 4th child.

<div id="wrapper3"> <div id="portfolio" class="container"> <div class="title"> <h2>The Team Members</h2> <span class="byline">This project is benefiting from the enthusiasm and expertise<br> of a variety of individuals from all over the globe.<br> Meet some of them here:</span> </div>

        <div class="column1">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum...</p>
            </div>
        </div>
        <div class="column2">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum ...</p>
            </div>
        </div>
        <div class="column3">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum ...</p>
            </div>
        </div>
        <div class="column4">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum ...</p>
            </div>
        </div>
        <div class="column5">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum....</p>
            </div>
        </div>
        <div class="column6">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum...</p>
            </div>
        </div>
        <div class="column7">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum ...</p>
            </div>
        </div>
        <div class="column8">
            <div class="box"><img src="images.jpg"/></a>
                <h3>name</h3>
                <p>Lorem ipsum ...</p>
            </div>

        </div>
    </div>

</div>

</div>

Could you post some html & css so we could better understand your situation? Thanks!

2 Answers

If it's as I think then you want to do something like this?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
</head>
<div id="wrap">
<body>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
    </body>
</html>

with css

#wrap {
    margin: 0 auto;
    width: 550px;
}

.box {
    display: inline-block;
    margin-left:10px;
    width: 100px;
    height: 100px;
    background: blue;
    border-radius: 5px;

}

.box:nth-child(4n) {
    clear:both;
    margin-right: 10px;
}

I think the solution provided by Aaron would work if the html was more like this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="wrap">
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
</div>
</body>
</html>

Gotta watch those opening and closing tags. The rest of the solution looks fine.

Yes good catch sorry... that will teach me not to retrofit someone else code on the fly. :-)