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 Screen
-
HTML And CSS Background Image Scaling To Fit Screens
-
Making Responsive Images With CSS Properties - BitDegree
-
Perfect Full Page Background Image - CSS-Tricks
-
Resizing Background Images With Background-size - CSS
-
CSS Background-size Property - W3Schools
-
How To Create A Full Page Image - W3Schools
-
HTML How To Make Background Image Fit Screen - YouTube
-
Html Background Image Fit Or Scale To Screen Size Code Example
-
How To Stretch A Background Image To Fit A Web Page - ThoughtCo
-
How To Resize An Image In HTML?
-
CSS Background Image Size To Fit Screen - Code Helper
-
How To Make Images Responsive With Examples - BrowserStack
-
HTML Background Image Fit Or Scale To Screen Size
-
How To Create A Responsive Background Image With CSS [Guide]