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
achievements
15,883 Pointscss for background image bootstrap
hi
I am looking for the proper css to make an image background responsive.This background-image includes tabs with a responsive table.What css should i use in bootstrap to do this?
6 Answers
Mike Bronner
16,395 PointsFor that type of scenario you probably want to use border-image and slice it: https://css-tricks.com/understanding-border-image/
achievements
15,883 Pointsi have done this but the top and the bottom of the background-image is not visible.What is your opinion?
Mike Bronner
16,395 PointsThat is expected behavior. "Cover" will crop the image so that it always fills the element it is applied to. You might try "fill", which resizes the image to always fit in the element it is applied to, without cropping.
Jordan Kaiser
5,438 PointsAn adjustment to the answers already give. The two attributes you could use are:
background-size: cover;
or
background-size: contain;
I don't believe there is an attribute called background-size: fill.
See this link for interactive examples. https://developer.mozilla.org/en-US/docs/Web/CSS/background-size
Mike Bronner
16,395 PointsThanks Jordan, that was what I meant :)
achievements
15,883 Pointsmy problem is in this link: http://www.fruitsandvegetables.site/ the background-image is responsive but the tabs and the table are outside of the image in a mobile.
achievements
15,883 Pointsthank you i will read the link!
Mike Bronner
16,395 PointsMike Bronner
16,395 PointsDepending on your use-case, you will want to use either
background-size: cover;or
background-size: fill;See https://www.w3schools.com/csSref/css3_pr_background-size.asp for details. Hope this helps :).