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 CSS Layout Techniques Display Modes Column Layout with Inline-Block

My secondary-content doesn’t display with a height of 100%

here is the part that does not work.

html,
body,
.main-wrapper,
.col{
    height: 100%;/*calculate based on the parent container*/
}

here is my whole css

/* Page Styles
================================ */


body{
    background-color: #edeff0;
    font:normal 1.1em/1.5 sans-serif;
    color: #222;


}
* {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
}
html,
body,
.main-wrapper,
.col{
    height: 100%;/*calculate based on the parent container*/
}

/*.main-wrapper{
    width: 90%;keep it from too wide
    margin: auto;/*center align the web page*/



/* Layout Element Colors
================================ */

.main-header       { background-color: red; }
.main-logo         { background-color: #5fcf80; }
.main-nav li       { background-color: #3f8abf; }
.primary-content   { background-color: #caebf6; }
.secondary-content { background-color: #bfe3d0; }
.main-footer       { background-color: #b7c0c7; }

/* Header, Banner and Footer Layout
================================ */

.main-header{
    padding: 20px;
    display: table;/*kind life a inline element*/
    width: 100%;
    min-height: 200px;

}
.main-banner{
    background: #ebedee;
    text-align: center;
    padding: 35px 15px;
}
.main-logo,
.main-nav,
.main-nav li{
    display: inline-block;/*takes only th espace they nned so can add more on the sam eline*/
}

.main-logo,
.mian-nav{
    display: table-cell;
    vertical-align: middle;

}

.main-logo{
    margin-right:15px;

}
.main-nav{
    padding: 50px;
}
.main-logo,
.main-nav li{
    border-radius: 5px;
}
.main-nav li{
    /*margin-right: -5px;fixed the space between li*/
    margin-right:10px;
}



.main-logo a, 
.main-nav a {
    color: white;
    text-decoration: none;
    display: block;
    text-align: center;
    padding: 10px 20px;

}

.main-footer{
    text-align: center;
    padding: 20px;
}

/*Column Layout
===================================*/
.col{
    padding: 20px;
    display: inline-block;
    margin-right: -5px;/* fix margin collapses*/
    vertical-align: top;/*fixed the 2 content posiitoned at the bottom.*/
}
.primary-content{
    width: 60%;
}

.secondary-content{
    width: 40%;
}
/*Mdia Queries
===================================*/
@media(max-width:768px){
    .main-logo,
    .main-nav,
    .main-nav li,
    .col,{
        display:block;
        width: initial;
        height: initial;
        margin: initial;

    }

    .main-nav{
        padding-left: initial;
    }
    .main-nav li{
        margin-top: 15px;
    }
    .main-banner{
        display: none;
    }
}

here is my html incase someone needs it.

<!DOCTYPE html>
<html>
<head>
    <title>Display Modes</title>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <div main-wrapper>
        <header class="main-header">
            <h1 class="main-logo"><a href="#">Logo</a></h1>
            <ul class="main-nav" syle="color:green">
                <li><a href="#">Link 1</a></li>
                <li><a href="#">Link 2</a></li>
                <li><a href="#">Link 3</a></li>
                <li><a href="#">Link 4</a></li>
            </ul>
        </header>
        <div class='main-banner'>
            <h1>This is our Main Heading!</h1>
            <p>Bacon ipsum dolor sit amet chicken pork</p>
        </div>
        <div class="primary-content col">
            <h2>Primary Content</h2>
            <p>Bacon ipsum dolor sit amet chicken pork ground round brisket corned beef ball tip shank tail salami filet mignon ham hock pork belly venison shankle. Pig kielbasa drumstick sausage pork chop boudin. Chicken t-bone salami pork chop, beef ribs kevin ham tri-tip beef venison biltong brisket.</p>
            <p>Venison strip steak meatball chicken, brisket prosciutto sirloin. Capicola drumstick brisket tri-tip salami. Chicken beef jerky, tail turkey prosciutto cow ham sirloin boudin tenderloin. Meatloaf tri-tip turducken brisket andouille, pork belly corned beef fatback hamburger.</p>
        </div>
        <div class="secondary-content col">
            <h3>Secondary Content</h3>
            <p>Strip steak tenderloin kevin swine meatloaf capicola, doner beef turducken pancetta corned beef pork loin shoulder.</p>
            <hr>
            <p>Pork filet mignon leberkas, tail swine venison pancetta turkey shoulder brisket chalkers likes hamburgers.</p>
        </div>
        <footer class="main-footer">
            <p>&copy;2014 Example Layout</p>
        </footer>
    </div>
</body>
</html>

Edited your markdown, for some reason it wasn't displaying the code correctly.

I am figuring the same issue. I try to wrap my css and html with

but it is not working. Any ideas?

thanks a lot

now it works normally and i haven’t changed anything... so weird.

I think you needed to make sure you have a line return by pressing enter before you type in the code block markdown, I run into that a lot when I am spacing out my paragraphs and blocks.

1 Answer

After your body tag, it looks like div main-wrapper doesn't have a class="" for the class value.

<div main-wrapper>

<!-- should be -->

<div class="main-wrapper">

it works properly now thank you so much!!!

No problem!