parent
6d7d954b4c
commit
310c249c62
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="display: flex; flex-direction: row; justify-content: center;box-shadow: 0 8px 8px rgba(0,0,0,0.1);width: 800px;">
|
||||
<div style="height: 40px; width: 800px;">
|
||||
<div class="top">
|
||||
<a>首页</a>
|
||||
<a>动画</a>
|
||||
<a>番剧</a>
|
||||
<a>音乐</a>
|
||||
<a>舞蹈</a>
|
||||
<div class="line"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<style>
|
||||
.top{
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
line-height: 40px;
|
||||
}
|
||||
.top span{
|
||||
cursor: pointer;
|
||||
}
|
||||
.line{
|
||||
height: 2px;
|
||||
width: 30px;
|
||||
background-color: pink;
|
||||
position: absolute;
|
||||
left: 73px;
|
||||
top: 45px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script type="text/javaScript" src="./jquery-3.7.1.min.js"></script>
|
||||
<script>
|
||||
|
||||
$('.top a').click(function(){
|
||||
console.log(12)
|
||||
let left = $('.top a')[0].offsetLeft;
|
||||
console.log(left)
|
||||
let thisOffset = ($(this).offset())
|
||||
let offsetLeft = thisOffset.left
|
||||
console.log(offsetLeft)
|
||||
$('.line').css('transform','translateX('+(offsetLeft-left)+'px'+')')
|
||||
})
|
||||
</script>
|
||||
</html>
|
Loading…
Reference in new issue