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.

Japneet Singh
4,675 Pointshow to size the background image in css
i want my background image to cover all of my header. so i used the cover property but it makes my image(.svg) bigger but the whole image is not visible.
2 Answers

Kieran Black
9,139 PointsHi Japneet,
Maybe
background-size: contain;
Would better suit?
Hope that helps.
KB

Jacob Mishkin
23,105 PointsI'm not sure how you have your header set up, but here is a great resource for scaling background images:
I hope this helps, if you need more help please post the HTML and CSS of the header, so we can see whats going on.

Japneet Singh
4,675 Points<header>
<h1>Welcome to Central Perk</h1>
</header>
header{
height: 640px;
background-image: url('C:/Users/Japneet/Desktop/minimalwall/pizza.svg');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}

Jacob Mishkin
23,105 PointsYou should read the documentation and if you get stuck, please ask where you are stuck. You need to know what your img size is as well, and if need be use photoshop to edit the size.

Japneet Singh
4,675 Pointsi used this as well
background size : 1000px 640px;
but the problem i am facing is that the width is not scaling only the height is

Jacob Mishkin
23,105 Pointsyou don't have a width set on on your header. have you tried to use percents? also you need to know what size the img is.
Japneet Singh
4,675 PointsJapneet Singh
4,675 Pointsnah tried that too but it pushes the image to left and its size remains the same that is 800*800