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

HTML

Philip Bradbury
Philip Bradbury
33,368 Points

Can't get grid system working?!?

Im trying to get my own grid system working and not having much look, the div's won't line up next to each other!! Ive checked everything i can think of, i was thinking it was to do with the float but i have them set up to float left. Any help would be great.

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css/normalize.css">
        <link rel="stylesheet" type="text/css" href="css/grid.css">
        <link rel="stylesheet" type="text/css" href="css/main.css">
    </head>
    <body>
        <div class= "content">
                <div class= "header">
                    <div class="grid-container">
                        <div class="grid_1">
                            <img src="menu.svg">
                        </div>
                        <div class="grid_3">
                            <a href="#" class="site-logo">Bakersfield</a>
                        </div>
                    </div>
                </div>
        </div>
    </body>
</html>
/*
Global
*/

.grid-container {
    padding-left: 10px;
    padding-right: 10px;
    margin-left: auto;
    margin-right: auto;
}

img {
    width:100%;
}



.grid-container > [class^="grid-"]{

    float: left;
    min-height: 1px;
    padding-left: 10px;
    padding-right: 10px;
    margin-left: 1.25%;
}

.grid-container > [class^="grid-"]:first-child {
    margin-left: 0;

}

.grid-container > [class^="grid-"]:last-child {
    float: right;

}

.grid_1 { width: 15.6%; } /* 75px/480 = px */
.grid_2 { width: 32.5%; } /* 156px/480px =  px */
.grid_3 { width: 49.4%; } /* 237px/480px = 0.235px */
.grid_4 { width: 66.3%; } /* 318px/480px = 0.32px */
.grid_5 { width: 83.1%; } /*  399px/480px = 0.405px */
.grid_6 { width: 100%;  } /* 480px/480px = 0.49px */


.group:after,
.grid-container:after {
    clear:both;
    content:' ';
    display:block;
}

2 Answers

I'm not sure if this will completely solve your issue, however I did notice that when your calling this code:

.grid-container > [class^="grid-"]

you are using a dash, when in the HTML you are using an underscore.

It should be .grid-container > [class^="grid_"]

Philip Bradbury
Philip Bradbury
33,368 Points

Thank you sooooooo much!! That was it, Due to that dash it wasn't calling the float after all. Second pair of eyes and all that! Thanks again

You're welcome! It happens to me all the time.