I want the symbol image to disappear on click. I have tried multiple approaches, many on this website but still no success. Do you think it is because of my z-indecies. Specifically, could it be that the z-index of symbol is less than the z-index of the background. I am new to web-programming so any help would be very much appreciated.
Thank you so much!
html/js/css
<!doctype html>
<html>
<head>
<title> Nomad </title>
<link rel = "stylesheet" type = "text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<section>
<img src = "bg.jpg" id = "bg">
<img src = "moon.png" id = "moon">
<img src = "DuneII.png" id = "mountain">
<img src = "Stretch.png" id = "road">
<img src="libra.png" id = "symbol">
</section>
<script>
let bg = document.getElementById("bg");
let moon = document.getElementById("moon");
let mountain = document.getElementById("mountain");
let road = document.getElementById("road");
window.addEventListener('scroll', function() {
var value = window.scrollY;
bg.style.top = value * 0.5 + 'px';
moon.style.left = value * 0.5 + 'px';
mountain.style.top = -value * 0.20 + 'px';
road.style.top = value * 0.15 + 'px';
})
$(document).ready(function(){
$("#symbol").click(function(){
$("#symbol").hide();
});
});
</script>
</body>
</html>
'''
*
{
margin: 0;
padding: 0;
}
body
{
background: #0a2a43;
min-height: 2000px;
}
section
{
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
section:before
{
content: '';
position: absolute;
bottom: 0;
width: 100%;
height: 100px;
background: linear-gradient(to top, #0a2a43, transparent);
z-index:10000;
}
section:after
{
content: '';
position: absolute;
top: 0;
left:0;
width: 100%;
height: 100%;
background: #0a2a43;
z-index: 10000;
mix-blend-mode: color;
}
section img
{
position: absolute;
top:0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
}
'''
Aucun commentaire:
Enregistrer un commentaire