-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path菜单动画.html
45 lines (40 loc) · 1.02 KB
/
菜单动画.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#line{
margin: 0 auto;
background-color: aqua;
transition: width 1s;
}
</style>
</head>
<body>
<div>
<h1 id="title" style="margin: 0;text-align: center">
切换效果
</h1>
<div id="line" style="width: 0"></div>
<button id="btn">click</button>
</div>
<script>
window.onload=()=>{
let line=document.getElementById('line')
let title=document.getElementById('title')
document.getElementById('btn').addEventListener('click',function (){
let width=parseInt(line.style.width)
if(width<100){
line.style.width='100px'
line.style.height='3px'
title.style.color='aqua'
}else {
line.style.width='0px'
title.style.color='#000'
}
})
}
</script>
</body>
</html>