timkatje
4/8/2019 - 8:58 PM

CSS Parallax

Hunter@Galvanize's sample parallax effect she likes to use on her pages

.parallax { 
    /* The image used */
    /* background-image: url("https://vignette.wikia.nocookie.net/dccu/images/4/44/Gotham_City_Promotional_Photo.jpg/revision/latest?cb=20170405014556"); */
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.9), rgba(255, 255, 255, 0.6)), url(photoURL);
  
    /* Set a specific height */
    height: 300px; 
    
    /* Text */
    color: white;
    font-size: 2rem;

    display: flex;
    justify-content: center;
    align-items: center;
  
    /* Create the parallax scrolling effect */
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
  }