The inability to display both a background image and a gradient overlay simultaneously can be frustrating. However, the solution is straightforward and lies in the correct order of elements within your CSS declaration.
To achieve the desired fading effect from black to transparent at the bottom of your background, the following steps are crucial:
.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; }
With these adjustments in place, the gradient overlay will now be displayed correctly on top of the background image, achieving the desired fading effect.
The above is the detailed content of How Can I Overlay a Gradient on a Background Image in CSS?. For more information, please follow other related articles on the PHP Chinese website!