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

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