How to create a fade effect with CSS on background with an image on top of it?

How to create a fade effect with CSS on background with an image on top of it?

I’m trying to replicate the image slider on https://www.masterclass.com/

enter image description here

Answer

To create that look you can set the image as the background of a div and then create a “black to clear to black” gradient in the div so it appears on top of the image.

.slideBanner{
background-image: url('../images/Ramsey.jpg');
}

.slideBanner{

background: -moz-linear-gradient(left, rgba(0,0,0,0.65) 0%, rgba(255,255,255,0) 48%, rgba(2,2,2,1) 100%); /* FF3.6-15 */

background: -webkit-linear-gradient(left, rgba(0,0,0,0.65) 0%,rgba(255,255,255,0) 48%,rgba(2,2,2,1) 100%); /* Chrome10-25,Safari5.1-6 */

background: linear-gradient(to right, rgba(0,0,0,0.65) 0%,rgba(255,255,255,0) 48%,rgba(2,2,2,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#020202',GradientType=1 ); /* IE6-9 */
}

I found this gradient code from one of the many gradient generators: http://www.colorzilla.com/gradient-editor/

with these settings:
enter image description here

Attribution
Source : Link , Question Author : Stanley Tan , Answer Author : Scott

Leave a Comment