0

I have two fixed images on my website. The first one without linear gradient works fine on safari but as soon as I try to apply linear-gradient to the second image it disappears. I put -webkit- prefix but no success. I followed this link as well. Can someone tell me what is causing this issue ?

.intro { 
-webkit-background: url('../images/intro.jpg') no-repeat;
background: url('../images/intro.jpg') no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: center center;
padding-top: 150px;
padding-bottom: 120px;
text-align: center;

}

.second-bg {
    background:  linear-gradient(to bottom, rgba(0, 0, 0, .2) 0%, rgba(0, 0, 0, .8) 59%, rgba(0, 0, 0, 0.65) 100%), url('../images/contact.jpg') no-repeat;
    background:  -webkit-linear-gradient(to bottom, rgba(0, 0, 0, .2) 0%, rgba(0, 0, 0, .8) 59%, rgba(0, 0, 0, 0.65) 100%), url('../images/contact.jpg') no-repeat;
    background-position: center center;
    background-size: cover;
    padding-top: 100px;
    background-attachment: fixed;
}
Community
  • 1
  • 1
code4life
  • 31
  • 4

2 Answers2

0

Have you tried putting image first and then the linear-gradient?

background:  url('../images/contact.jpg') no-repeat, linear-gradient(to bottom, rgba(0, 0, 0, .2) 0%, rgba(0, 0, 0, .8) 59%, rgba(0, 0, 0, 0.65) 100%) no-repeat;
background:  url('../images/contact.jpg') no-repeat, -webkit-linear-gradient(to bottom, rgba(0, 0, 0, .2) 0%, rgba(0, 0, 0, .8) 59%, rgba(0, 0, 0, 0.65) 100%) no-repeat;

The image is there, but it's under linear-gradient and therefore not visible.

Keammoort
  • 3,075
  • 15
  • 20
0

The issue lies on linear gradient (to bottom .... ) I changed it to (left bottom ... )

    background: -webkit-linear-gradient(left bottom, rgba(0, 0, 0, .5) 29%, rgba(0, 0, 0, 0.65) 100%), url('../images/contact.jpg') no-repeat;

and solved the problem. Another thing to point out is the image has to come after gradient otherwise it will not work.

Solution:

  1. change the gradient to (left bottom ...)
  2. image url has to come after gradient
code4life
  • 31
  • 4