Home >Web Front-end >CSS Tutorial >Video: Scalable Backgrounds in CSS
The parallax scrolling effect can be achieved in CSS by using the background-attachment property and setting its value to fixed. This will cause the background image to remain fixed while the content scrolls over it. Here’s an example:
body {
background-image: url('image.jpg');
background-attachment: fixed;
}
To create a full-screen background image in CSS, you can use the background-size property and set its value to cover. This will scale the image to cover the entire container. Here’s an example:
body {
background-image: url('image.jpg');
background-size: cover;
height: 100vh;
}
To change the opacity of a CSS background image, you can use the ::after pseudo-element to create an overlay with a specific opacity. Here’s an example:
body::after {
content: '';
background: url('image.jpg');
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
The above is the detailed content of Video: Scalable Backgrounds in CSS. For more information, please follow other related articles on the PHP Chinese website!