
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Achieve Responsiveness for background image with CSS
You can try to run the following code to achieve responsiveness for background image with CSS −
Example
<!DOCTYPE html> <html> <head> <meta name = "viewport" content="width = device-width, initial-scale = 1.0"> <style> div { width: 100%; height: 300px; border: 2px dashed blue; background-image: url('https://www.tutorialspoint.com/python/images/python-data-science.jpg'); background-repeat: no-repeat; background-size: contain; } </style> </head> <body> <p>To check the effect, you need to resize the browser.</p> <div></div> </body> </html>
- Related Articles
- Repeat the background image with CSS
- Specify the background image with CSS
- Set the Background Image Position with CSS
- Set background image as fixed with CSS
- CSS background-image property
- Show the background image only once with CSS
- Setting Background Image using CSS
- Set the background image of an element with CSS
- How to create a blurry background image with CSS?
- Repeat the background image both horizontally and vertically with CSS
- Set a linear gradient as the background image with CSS
- Set a radial gradient as the background image with CSS
- How to create a full-page background image with CSS?
- Achieve Glow Effect with CSS Filters
- Achieve X-Ray effect with CSS

Advertisements