scully_a
Coder
Hello, I am trying to make an image map with multiple clickable areas that will bring up pop ups.
The problem that I have is that the image also needs to move with cursor in a set frame. To achieve this function I set the image as a background image in the css. I do not know if there is anyway to set an image map on an image that is located in the css file.
If not, then I need to figure out how to still get the image to move with cursor movement in a set frame, while image resides in the HTML file so I can create an image map for it.
I am very novice at coding, this is for an art project. I do not know if this is at all achievable, but damn I am trying.
If anyone has any ideas, I would appreciate the help.
HTML:
<!DOCTYPE html>
<lang=en>
<html>
<head>
<title>Unum project</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="210203_overflow test.css">
<!--background move with cursor-->
<meta name="viewport" content="width=device-width, initialscale=1.0">
<!--background move with cursor-->
</head>
<body>
<!--background move with cursor-->
<div class="box" id="box"
value="PLAY" onmouseover="play()" loop="loop">
<!--music plays on image click-->D
</div>
<script>
const el = document.querySelector('#box')
el.addEventListener('mousemove', (e) => {
el.style.setProperty('--x', -e.offsetX + 'px')
el.style.setProperty('--y', -e.offsetY + 'px')
})
</script>
<!--background move with cursor-->
<!--music plays on image click-->
<script>
function play(){
var audio = document.getElementById("audio");
audio.play();
}
</script>
<audio id="audio" src="262259__shadydave__snowfall-final.mp3" ></audio>
<audio src="262259__shadydave__snowfall-final.mp3" id="bg_music" loop="loop" ></audio>
<!--music plays on image click-->
<!--image mapping-->
</body>
</html>
CSS:
body {
/*background move with cursor*/
height: 100vh;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
background-color: #222;
/*background move with cursor*/
}
.box {
/*background move with cursor*/
width: 800px;
height: 600px;
border: 1px solid white;
background-image: url(images/scene1/big-image.jpg);
--x: 0px;
--y: 0px;
background-position: var(--x) var(--y);
background-size: 3000px;
/*background move with cursor*/
}