-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_events_hw.html
49 lines (48 loc) · 1.39 KB
/
js_events_hw.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body{height: 4000px; margin: 0; }
#coord{
width: 200px;
height: 100px;
text-align: center;
//position: absolute;
position: fixed;
font-size: 30px; font-weight: bold;
color: midnightblue;
}
#head{
color: gainsboro; font-size: 40px; letter-spacing: 5px;
width: 100%; height: 10%; text-align: center;
background: #555555; position: absolute;
}
</style>
</head>
<body>
<header id="head">Заголовок сайта:</header>
<!-- <div id="coord">x: 125 ; y: 52</div> -->
<script>
/*let coordinate=document.querySelector("#coord");
//console.dir(coordinate);
document.addEventListener('mousemove', function (event) {
coordinate.innerHTML= 'x:'+(event.clientX-pageXOffset)+'; y: '+(event.clientY-pageYOffset);
});*/
let el=document.body;
console.dir(el);
let el1=document.body.getElementsByTagName('header')[0];
console.dir(el1);
document.addEventListener("scroll", function (event){
if(document.body.scrollTop>400){
console.dir(pageYOffset);
el1.style.top=pageYOffset+'px';
}
else{
el1.style.top=0+'px';
}
});
</script>
</body>
</html>