1

so I'm trying to achieve parallax scrolling with just css3. I've stuck to the w3schools tutorial but my image isn't displaying on my web page. here is my HTML:

    <!--Main Content-->
<main>
    <div class="parallaxBG">

    </div>
</main>

and here is my CSS:

.parallaxBG {
    background-image: url("Resources/Images/2018-01-03_17.07.41.png");
    height: 100%;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

can anyone answer?

1
  • 1
    Is your body and html set to height: 100%; also? If not, your div won't have any height without anything inside it. Commented Jan 5, 2018 at 0:21

1 Answer 1

4

Set all of your parent elements to have a height of 100% as well otherwise your parallax div will have no height fill 100% of and will just have a height of 0 and nothing will show until you put some content in that div.

So like:

body, html, main{height:100%;}
Sign up to request clarification or add additional context in comments.

1 Comment

It appears I've forgotten to set the height of my <main> tag to 100%. Thank you for the quick response!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.