Vincent Toonen Vincent Toonen - 2 months ago 9
CSS Question

Background image in css and giving it parallax

I have question. I am using materialize CSS. And I tried parallax with the html


<img class="parallax">
tag but is there a way to give you're background image in CSS but also making it parallax.

My Example code:

Content html:

<div class="row parallax-container">
<div class="parallax">
<div class="intro headerBackground">
<h1 class="grey-text text-lighten-5">Data</h1>
<h5 class="grey lighten-4 grey-text text-darken-1">Data</h5>
</div>
</div>
</div>


Content CSS:

.intro
{
text-align: center;
padding-top: 13%;
padding-bottom: 13%;
margin-bottom: 50px;
}

.intro h1
{
font-weight: 900;
text-transform: uppercase;
}

.intro h5
{
text-transform: uppercase;
background-color: #fafafa;
padding: 10px;
display: inline-block;
font-size: 1.2rem;
}
.headerBackground{
height:800px;
background-image:url('images');
background-repeat:no-repeat;
background-position:center;
background-size: cover;
}

Answer

Please Try:-

<div class="row parallax-container">
<div class="parallax headerBackground">
    <div class="intro">
        <h1 class="grey-text text-lighten-5">Data</h1>
        <h5 class="grey lighten-4 grey-text text-darken-1">Data</h5>
    </div>
</div>