Parallax effect only working on background image and not text

Viewed 82

I'm currently following the tutorial on parallax effects on W3Schools. Basically, I have it so where the parallax is scrolling over my background correctly, but it's not scrolling over the text as well.

I tried a lot of things but it still doesn't work. I also saw one other post about this issue, but their code differed a lot from mine so it was hard to understand.

Here is the image of what is happening (the words are scrolling up with the page):
words are scrolling up with the page

Here's my code:

*{
    box-sizing: border-box;
}
body{
    margin: 0px;
    background-color: #ffffff;
}

ul{
    text-align: center;
    padding: 0px 20px;
    margin: 12px auto;
    list-style: none;
    position: fixed;
    z-index:10;
    top: 0;
}

ul, li{
    display: inline-table;
}

li{
    margin: 10px 30px;
    font-size: 15px;
    color: #42385d;
    font-weight: bold;
    font-family: 'Roboto Slab', serif;
}


.navbar{
    background-color: #ffcfda;
    position: fixed;
    width: 100%;
    border-bottom: 1px solid #ffcfda;
    z-index: 10;
    height: 70px;
    top: 0;
    overflow: hidden;
}

#parallax{
    background-image: url("pinkbackground.jpg");
    min-height: 100vh;

    background-attachment: fixed;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    position: relative;
}

.transition{
    height: 200px;
    background-color: #42385d;
    width: 100%;
}
.intro-text{
    text-align: center;
    width: 100%;
    color: #42385d;
    padding: 37vh;    
    height: 100vh;
    width: 100%;
    font-size: 50px;
    font-family: 'Roboto Slab', serif;
    position: relative;
    background-attachment: initial;
}

.question{
    font-size: 30px;
    font-family: 'Roboto Mono', monospace;   
    color: #42385d;
    font-weight: bolder;
    padding-top: 40px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
    <title>schpiel - Applying, Made Easier</title>
    <!--meta data-->
    <meta name = "viewport" content = "width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <meta name = "description" content =
     "schpiel, like the name implies, makes applying easier. 
    no, it doesn't sound like that? :(. Using our new autofill 
    feature, with one click you can apply instantly!">

    <!--styling-->
    <link rel="stylesheet" href="style.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@1,300&family=Roboto+Slab&display=swap" rel="stylesheet">
    <link rel="icon" href="https://i.imgur.com/RoPgdJh.jpg">
</head>
<body>
    <div id="navigation">
        <nav class="navbar";>
            <ul>
                <li>
                    <a>
                        Home
                    </a>
                </li>
                <li>
                    <a>
                        About
                    </a>
                </li>
                <li>
                    <a>
                        Contact
                    </a>
                </li>
            </ul>
            </nav>
        </div>
    <div id="parallax">
        <div class="intro-text">
            text 
                <br>
              here
        </div>
    </div>

    <div class="transition"></div>
    <section id="whatIsSchpiel">
        <div class="question">
            What is schpiel?
            </div>
        <div class="answer">
            sscsdafads
        </div>
    </section>
</body>
<footer>
</footer>

0 Answers
Related