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 trialJapneet 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,117 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,117 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,117 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