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 Float Layout Mobile First Layout

text spilling into the footer

Hello,

If you narrow the viewport to 707px, you will see the text in the extra-content and primary-content column spill into the footer. What can add in the media query to contain the text inside their respective columns at the break point of 707px? cheers!

<!DOCTYPE html>
<html>
<head>
    <title>Floats</title>
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="css/normalize.css">
    <style>

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

* {
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
body {
    font: normal 1.125em/1.5 sans-serif;
    color: #222;
    background-color: #edeff0;
}
.main-wrapper{
width:90%;
margin:0 auto;
}

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

.main-header       { background-color: #384047; }
.main-logo a       { background-color: #5fcf80; }
.main-nav a        { 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:15px;

}

.main-logo{
margin-top:5px;
margin-bottom:0;
border-radius:5px;
}
.main-nav {
list-style-type:none;
padding-left:0;

}

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

}
.main-nav li{
margin-top:15px;
border-radius:5px;
}
/*size the column
=========================================*/
.col{
padding:20px;

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


}
.extra-content, .main-banner{
display:none;
}
.feat-img{
width:100%;
padding:4px;
border:1ps dashed black;
margin-right:10px;
margin-bottom:10px;

}
/*media 
================================================*/
@media(min-width:769px)
{
    .main-logo, .main-nav, .main-nav li{
    float:left;

    }
    .main-logo{
    margin-right:40px;
    }
    .main-nav li{
    margin-left:15px;

    }
    /*columns
    ========================================*/
    .col{
    float:left;
    width:25%;

    }
    .primary-content{
    width:50%;

    }
    .col:last-child{
    float:right;

    }
    .main-banner, .extra-content{
    display:block;

    }
    .main-banner{
    text-align:center;
    background:#dfe2e4;
    padding:5px;

    }
    .feat-img{
    width:50%;
    margin-right:10px;
    margin-bottom:10px;
    float:left;

    }
    html, body, .main-wrapper, .content-row,.col{
    height:100%;
    }

    /*clear fix
    =======================================*/
    .group::after{
    content:"";
    display:table;
    clear:both;

    }
}
@media(max-width:600px)
{
    .main-wrapper{max-width:85%;}
    body{font-size:1em}



}   
    </style>
</head>
<body>
    <div class="main-wrapper">
        <header class="main-header group">
            <h1 class="main-logo"><a href="#">Logo</a></h1>
            <ul class="main-nav">
                <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 the Main Banner Heading</h1>
            <p>Andouille pork chop pancetta drumstick ground round beef ribs swine brisket ham.</p>
        </div>
        <div class="content-row group">
            <div class="extra-content col">
                <h3>Extra Content</h3>
                <p>Filet mignon turkey flank doner strip steak. Frankfurter ham hock turkey, venison sirloin pig chuck shank capicola hamburger doner spare ribs boudin.</p>
                <hr>
                <p> Drumstick bresaola meatloaf ham hock salami tri-tip landjaeger beef filet mignon biltong boudin turkey.</p>
            </div>
            <div class="primary-content col">
                <h2>Primary Content</h2>
                <img class="feat-img" src="http://lorempixel.com/400/300">
                <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>
        </div>
        <footer class="main-footer">
            <p>&copy;2014 Example Layout</p>
        </footer>
    </div>
</body>
</html>

6 Answers

idan ben yair
idan ben yair
10,288 Points

Hi, try to define a larger height for the content:

.content {
  height: 710px;
}

that should prevent any text from over lapping to the footer. Let me know if that helped :)

Hello,

i addded your style into the media query, but it didnt work. Did you test on your end by narrowing the viewport to around 707px? the text is still splilling on my side. thanks!

<!DOCTYPE html>
<html>
<head>
    <title>Floats</title>
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="css/normalize.css">
    <style>

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

* {
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
body {
    font: normal 1.125em/1.5 sans-serif;
    color: #222;
    background-color: #edeff0;
}
.main-wrapper{
width:90%;
margin:0 auto;
}

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

.main-header       { background-color: #384047; }
.main-logo a       { background-color: #5fcf80; }
.main-nav a        { 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:15px;

}

.main-logo{
margin-top:5px;
margin-bottom:0;
border-radius:5px;
}
.main-nav {
list-style-type:none;
padding-left:0;

}

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

}
.main-nav li{
margin-top:15px;
border-radius:5px;
}
/*size the column
=========================================*/
.col{
padding:20px;

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


}
.extra-content, .main-banner{
display:none;
}
.feat-img{
width:100%;
padding:4px;
border:1ps dashed black;
margin-right:10px;
margin-bottom:10px;

}
/*media 
================================================*/
@media(min-width:769px)
{
    .main-logo, .main-nav, .main-nav li{
    float:left;

    }
    .main-logo{
    margin-right:40px;
    }
    .main-nav li{
    margin-left:15px;

    }
    /*columns
    ========================================*/
    .col{
    float:left;
    width:25%;

    }
    .primary-content{
    width:50%;

    }
    .col:last-child{
    float:right;

    }
    .main-banner, .extra-content{
    display:block;

    }
    .main-banner{
    text-align:center;
    background:#dfe2e4;
    padding:5px;

    }
    .feat-img{
    width:50%;
    margin-right:10px;
    margin-bottom:10px;
    float:left;

    }
    html, body, .main-wrapper, .content-row,.col{
    height:100%;
    }

    /*clear fix
    =======================================*/
    .group::after{
    content:"";
    display:table;
    clear:both;

    }
}
@media(max-width:600px)
{
    .main-wrapper{max-width:85%;}
    body{font-size:1em}
    .content {
  height: 710px;
}




}   
    </style>
</head>
<body>
    <div class="main-wrapper">
        <header class="main-header group">
            <h1 class="main-logo"><a href="#">Logo</a></h1>
            <ul class="main-nav">
                <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 the Main Banner Heading</h1>
            <p>Andouille pork chop pancetta drumstick ground round beef ribs swine brisket ham.</p>
        </div>
        <div class="content-row group">
            <div class="extra-content col">
                <h3>Extra Content</h3>
                <p>Filet mignon turkey flank doner strip steak. Frankfurter ham hock turkey, venison sirloin pig chuck shank capicola hamburger doner spare ribs boudin.</p>
                <hr>
                <p> Drumstick bresaola meatloaf ham hock salami tri-tip landjaeger beef filet mignon biltong boudin turkey.</p>
            </div>
            <div class="primary-content col">
                <h2>Primary Content</h2>
                <img class="feat-img" src="http://lorempixel.com/400/300">
                <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>
        </div>
        <footer class="main-footer">
            <p>&copy;2014 Example Layout</p>
        </footer>
    </div>
</body>
</html>
idan ben yair
idan ben yair
10,288 Points

try to remove height all together from content and see if it will adjust. sometimes that works.

Sorry lovell, I do not have an account with codepen. thanks

you don't need one...it's for people like us on treehouse to share via a link. No need to sign up...Free and easy.

lovell, wouldn't it be easier to just copy and paste the above code into and editor. I thought most of us did that.

Anyway, what is copepen ? Where in codepen do I go to do exactly what I did here, paste the whole code.

Sorry for sounding cheeky; but this whole thing feels redundant, not sure

cheers!