What can I do to set the background-image size to 100% inside a border? Or is it not possible? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What can I do to set the background-image size to 100% inside a border? Or is it not possible?

In a paragraph element, I created a border, set the width and height to 50%. And set the background image, the size of thr image is pretty big. And now only half (top-left to the other half) shows up since the paragraph is on the left side.

5th Jul 2022, 3:42 PM
Meow Meow
Meow Meow - avatar
4 Answers
+ 3
Normally it should be 100% inside the border… Do you habe Padding? When you have 0 Padding it should work
5th Jul 2022, 3:54 PM
Janne
Janne - avatar
+ 2
You can use background-size: 100% 100%; to set size of background image to fit full container. Sometimes this is not enought and you need to play with other properties like background-repeat, background-position, or other background-size values Check this guide for background size https://css-tricks.com/almanac/properties/b/background-size/
5th Jul 2022, 5:11 PM
PanicS
PanicS - avatar
+ 1
I'll try it tomorrow, too exhausted rn, thanks for answering 😊
5th Jul 2022, 4:02 PM
Meow Meow
Meow Meow - avatar
+ 1
PanicS alright, thank you 😊
6th Jul 2022, 11:32 AM
Meow Meow
Meow Meow - avatar