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
Mark Bacolcol
7,354 PointsHow do you show the full height of a background image on a div?
So I want to create a div with text and a background image, but I was wondering how do you show the full height of the image? What I'm experiencing is that the background image height is relative to the content inside the div. Is there a way to always have the full background image showing?
2 Answers
Mikey Neilson
Front End Web Development Techdegree Student 12,642 PointsHi Mark I think you use the background-size property with the value of cover.
background-size : cover;
Mark Bacolcol
7,354 PointsMay have to set the image as background for the body, but seems a little unconventional. Open to other alternatives.
Mark Bacolcol
7,354 PointsMark Bacolcol
7,354 PointsOn a smaller screen that solves the height problem, but the width exceeds the size of my screen.
On a larger screen it doesn't show the entire height of the image.