Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Responsive header background image

Hi,

I'm having a little trouble with something, I'm wanting to make the image that I'm using as a background on my header to be responsive and size accordingly with different screen sizes.

the image itself is re-sizing but what I really want to do is make the actual area that the image is in bigger on different screen sizes.

Below is a snippet of my css

/* Header Layout ---------------*/

.main-header{
    background-image: url(../img/yoga-banner.png);
    background-size: cover;
    padding-bottom: 100px;
    background-repeat: no-repeat;
    margin-bottom: 25px;
}

I've tried to re-size with a media query by adding padding to the bottom, whilst that does make the image bigger my text that is centered has a huge gap at the bottom to due the padding.

Any help with this would be greatly appreciate :)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

My best suggestion is to try not making the padding in pixels but rather in percent. That way the percent should remain the same regardless of the screen size. Just a thought! :)

thanks for the suggestion :) I actually figured out the really noob mistake after posting this but I still have a problem with my text if you are able to help

My text is not aligning properly, it's centered in the middle but I still have the gap at the bottom

Actually I fixed the text! Thanks for your help! :D