Home >Web Front-end >CSS Tutorial >Why Doesn't My CSS Gradient Overlay Appear Over My Background Image?
Gradient Overlay on Background Images: A CSS Conundrum Solved
Attempting to apply a gradient overlay to your background image for an elegant fading effect can be a puzzling task. Despite specifying both the gradient and the image in the CSS, only one layer seems to display.
To resolve this issue, revise the code structure and ensure the URL for the background image is placed at the end of the style declaration. The correct syntax is as follows:
.css { background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%), url('https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a') no-repeat; height: 200px; }
This modification ensures that the background image is placed on top of the gradient layer, resulting in a seamless blend.
The above is the detailed content of Why Doesn't My CSS Gradient Overlay Appear Over My Background Image?. For more information, please follow other related articles on the PHP Chinese website!