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

How to increase the height of the background without affecting the other elements?

I have two backgrounds. The top is black and the bottom is green. I am having trouble changing the height of either the black or green background without it moving the other elements on the page. What can I do to increase or decrease the height of either the black or green background without it affecting the other elements? I have attached the code below. http://codepen.io/Johned22/pen/KgxpxQ Thanks in advance

2 Answers

You have to first understand that the body has the black background with the gradient (this overrides the green background that you define on it earlier). The green background ends up just applied to the html element. The body of the document is only going to be as tall as the content of it unless you specify a height for it. Since #services is given a height of 200px and is the only content right now, that ends up the height of the body element, and therefore that is as tall as the black section will be. You can adjust the height of the black section by either setting the body to a fixed height (like 100% or 500px) or adding content to make it taller.

Thanks for your help. That solved my problem.