I’m trying to make an image that does a parallax when you scroll in html, and it works as long as the <style>
with the details of the image is inside the .html
file, but as soon as I move it to the .css
file it stops working.
This is the class
I’m using
<style>
.parallax {
background-image: url("images/background.png");
min-height: 100px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>
and this is how I print it
<div class="parallax"></div>
I tried moving the class
inside the css
file by removing the <style>
tags but it stopped working even if it gave me no errors at all
.parallax {
background-image: url("images/background.png");
min-height: 100px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
I know I could just leave it inside the HTML file but I want to put that inside the css.
This page is also a redirect from another page that uses the same css file, does that have to do with the fact that this is not working?
Am I missing something? I just started html and I’m lost.
2
Answers
It seems like you are not linking the stylesheet to the html document! Did your write in the html doc
in the
<head>
tags?If you want to place your styles in a css file. You need to call the file location in the .html file.
Ex: <link rel="Stylesheet" href="styles.css"
By this way the html file will be able to call the css file and the styles will work.