Background Size - Tailwind CSS
Có thể bạn quan tâm
| Class | Styles |
|---|---|
| bg-auto | background-size: auto; |
| bg-cover | background-size: cover; |
| bg-contain | background-size: contain; |
| bg-size-(<custom-property>) | background-size: var(<custom-property>); |
| bg-size-[<value>] | background-size: <value>; |
Examples
Filling the container
Use the bg-cover utility to scale the background image until it fills the background layer, cropping the image if needed:
Filling without cropping
Use the bg-contain utility to scale the background image to the outer edges without cropping or stretching:
Using the default size
Use the bg-auto utility to display the background image at its default size:
Using a custom value
Use the bg-size-[<value>] syntax to set the background size based on a completely custom value:
<div class="bg-size-[auto_100px] ..."> <!-- ... --></div>For CSS variables, you can also use the bg-size-(<custom-property>) syntax:
<div class="bg-size-(--my-image-size) ..."> <!-- ... --></div>This is just a shorthand for bg-size-[var(<custom-property>)] that adds the var() function for you automatically.
Responsive design
Prefix a background-size utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:
<div class="bg-auto md:bg-contain ..."> <!-- ... --></div>Learn more about using variants in the variants documentation.
Từ khóa » Html Resize Background Image To Fit Div
-
Resizing Background Images With Background-size - CSS
-
Resize Background Image In Div Using Css [duplicate] - Stack Overflow
-
CSS Background-size Property - W3Schools
-
How To Fit Background Image To Div Size Code Example - Code Grepper
-
Background Image Fit To Div Code Example - Code Grepper
-
Perfect Full Page Background Image - CSS-Tricks
-
How To Resize Background Images With CSS3 - W3docs
-
Css Background Image Size To Fit Div - Add Multiple ... - Pakainfo
-
How To Resize An Image In HTML?
-
How To Set Size Of Background Image Fit To The Div
-
A Deep Dive Into Object-fit And Background-size In CSS
-
How To Stretch A Background Image To Fit A Web Page - ThoughtCo
-
How To Auto-resize An Image To Fit A Div Container Using CSS?