I'm making a page where your click on the page is recorded and remains in the div it was clicked.
But as soon as you scroll one of the four divs, the .note
div (containing the "touch" text) is supposed to be scrolled with the div it is in.
I've tried a few things but I can't seem to manage a way to make this work...
$(document.body).click(function (c) {
var tw = 100/2;
var th = 30/2;
$('.note:last').clone().appendTo('.wrapper');
$('.note:last').css({ position: 'absolute', display: "block",
left: c.pageX-tw, top: c.pageY-th
});
// $('.note').remove();
});
body{
font-family: sans-serif;
font-size: 1.3rem;
margin: 0;
background-color: DarkSlateGray;
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 5px;
grid-auto-rows: minmax(100vh, auto);
height: 100vh;
}
.one {
position: relative;
overflow: scroll;
height: 100%;
background-color: tan;
grid-column: 1 / 2;
}
.two {
position : relative;
overflow: scroll;
background-color: tan;
grid-column: 2 / 3;
height: 100%;
}
.three {
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */
overflow: scroll;
background-color: tan;
grid-column: 3 / 4;
height: 100%;
}
.four {
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */
overflow: scroll;
background-color: tan;
grid-column: 4 / 4;
height: 100%;
}
.one::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
.two::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
.three::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
.four::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
.note{
text-align: center;
width:100px;
height: 30px;}
.direction{
position: absolute;
bottom : 0;
width: 25vw;
text-align: center;
}
.username{
background-color: red;
display: block;
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrapper">
<div class="one">
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
</div>
<div class="two">
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
br<br>
</div>
<div class="three"></div>
<div class="four"></div>
</div>
<div class="note"></div>
<div class ="texte"></div>
<div class="note" style="display: none;">touch</div>