+ 4
How I adjust the width and height of the background image in the text box?
give me example for this https://code.sololearn.com/W296BqQlscDY/?ref=app
3 odpowiedzi
0
background-size: width height;
the width and height can be set in pixels or %
100% is the entire width or height of the element itself, in this case
+ 4
okay I got it! thanks
+ 4
Background-size can use more (css) units than just pixels (px) and percents (%)... and provide also useful special values:
background-size:cover; /* fit the image to the element size, keeping ratio and cropping if necessary */
background-size:contains; /* fit also the image to the element size, keeping ratio but without cropping (repeating or leaving empty space on side greater than the one of the image ratio, regarding of use of 'background-repeat' */
Anyway, these special values are often (but not always) used with:
background-repeat:no-repeat; /* in those kind of context, repeatition is often not necessary */
background-position:center center; /* to guarant that the center of image is always visible */