You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.9 KiB
83 lines
1.9 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="css.css">
|
|
<title>Vesmir</title>
|
|
</head>
|
|
<body>
|
|
<div class="section" id="zacatek">
|
|
|
|
|
|
<h1>Ahoj</h1>
|
|
|
|
|
|
|
|
</div>
|
|
<div class="section" id="cerna">
|
|
|
|
<h1 style="color: aliceblue;">Ahoj</h1>
|
|
|
|
</div>
|
|
|
|
<div class="section" id="hvezda">
|
|
|
|
<h1>Ahoj</h1>
|
|
|
|
</div>
|
|
<div class="section">
|
|
|
|
<h1>Ahoj</h1>
|
|
|
|
</div>
|
|
<div class="section">
|
|
|
|
<h1>Ahoj</h1>
|
|
|
|
</div>
|
|
<div class="section">
|
|
|
|
<h1>Ahoj</h1>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
function handler() {
|
|
let cerna = document.querySelector('#cerna');
|
|
let cerna_rect = cerna.getBoundingClientRect();
|
|
console.log(cerna_rect.top);
|
|
let value = Math.ceil(255 * (cerna_rect.top / cerna_rect.height));
|
|
document.body.style.backgroundColor = "rgb(" + value + "," + value + "," + value + ")";
|
|
let opacity = (cerna_rect.top / cerna_rect.height);
|
|
console.log("Opacity: " +opacity);
|
|
|
|
if (value >= 0 && value <= 255) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
window.addEventListener('load', handler, false);
|
|
|
|
window.addEventListener('scroll', handler, false);
|
|
|
|
window.addEventListener('resize', handler, false);
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|