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

Text Spilling out of Div (codepen inside)

Hello,

I am working on a site and I am having an issue with some of the media queries. When the site goes below the 480px break point the text in the <header> section (gray banner) spills out of its container as shown in the image below.http://s24.postimg.org/557drjmyd/spilling.png

I have tried several different things but seem to be having difficulty coming up with a solution. Here is the codepen: http://codepen.io/anon/pen/Ggxpzz

Thanks in advance

4 Answers

The primary reason is because you have a finite height and quite a bit of left padding while placing too much content in that amount of available space.

There are numerous potential solutions:

  • remove height
  • reduce padding-left
  • reduce font-size (not really recommended)
  • set overflow: auto to induce scrolling (not recommended)

My preference would be using both points 1 & 2 above -- remove height and, if you still want the text (content) on the right, set padding-left: 50%.

Reduce your left-padding at smaller resolutions

.header { 
  padding-left: 15px; 
} 

@media (min-width: 768px) {
  .header {
    padding-left: 225px;
  }
}

Thank you very much Colin Bell

Thank you once again everyone, very grateful for your replies.