当前位置:网站首页>(12) Somersault cloud case (navigation bar highlights follow)
(12) Somersault cloud case (navigation bar highlights follow)
2022-07-01 04:15:00 【superfortunate】
- The mouse passes through a small li, Tumbling clouds follow to the current small li Location
- The mouse leaves this little li, Somersault cloud returns to its original position
- Mouse click on a small li, The somersault cloud will stay on this small li The location of
- Still use animation functions for animation effects
- The original location of the tumbling cloud was 0
- The mouse passes through a small li, Make the current small li Of offsetLeft Position as the target value
<body>
<div id="c_nav" class="c-nav">
<span class="cloud"></span>
<ul>
<li><a href="javascrit:;"> Home news </a></li>
<li><a href="javascrit:;"> faculty </a></li>
<li><a href="javascrit:;"> event planning </a></li>
<li><a href="javascrit:;"> The enterprise culture </a></li>
<li><a href="javascrit:;"> Recruitment information </a></li>
<li><a href="javascrit:;"> Company profile </a></li>
<li><a href="javascrit:;"> Yamaguchi travels </a></li>
<li><a href="javascrit:;"> Mecha is really </a></li>
</ul>
</div>
</body>
<style>
* {
margin: 0;
padding: 0
}
ul {
list-style: none;
}
body {
background-color: black;
}
.c-nav {
width: 900px;
height: 42px;
background: #fff url(images/rss.png) no-repeat right center;
margin: 100px auto;
border-radius: 5px;
position: relative;
}
.c-nav ul {
position: absolute;
}
.c-nav li {
float: left;
width: 83px;
text-align: center;
line-height: 42px;
}
.c-nav li a {
color: #333;
text-decoration: none;
display: inline-block;
height: 42px;
}
.c-nav li a:hover {
color: white;
}
.cloud {
position: absolute;
left: 0;
top: 0;
width: 83px;
height: 42px;
background: url(images/cloud.gif) no-repeat;
}
</style>
<script>
window.addEventListener('load',function(){
var cloud = document.querySelector('.cloud');
var c_nav = document.querySelector('.c-nav');
var lis = c_nav.querySelectorAll('li');
var current = 0;// This is where the tumbling cloud starts
for(var i = 0; i < lis.length; i++) {
lis[i].addEventListener('mouseenter',function(){
animate(cloud,this.offsetLeft);
})
lis[i].addEventListener('mouseleave',function(){
animate(cloud,current);// Go back to the starting position
})
// When the mouse clicks , Take the current position as the target value
lis[i],addEventListener('click',function(){
current = this.offsetLeft;
});
}
})
</script>
animate() For the animation function used before .
Happy study !
边栏推荐
- TASK04|數理統計
- [JPCs publication] the Third International Conference on control theory and application in 2022 (icocta 2022)
- 392. judgment subsequence
- [Master / slave] router election in DD message
- Analysis and case of pageobject mode
- HoloLens2开发环境搭建及部署app
- 熊市下的Coinbase:亏损、裁员、股价暴跌
- 线程常用方法与守护线程
- ThreeJS开篇
- After many job hopping, the monthly salary is equal to the annual salary of old colleagues
猜你喜欢
Possible problems and solutions of using scroll view to implement slider view
Network metering - application layer
Jenkins自动清理构建历史
Ospfb notes - five messages [ultra detailed] [Hello message, DD message, LSR message, LSU message, lsack message]
Obtain detailed ideas for ABCDEF questions of 2022 American Games
25.k sets of flipped linked lists
陈宇(Aqua)-安全-&gt;云安全-&gt;多云安全
[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached
The problem of integrating Alibaba cloud SMS: non static methods cannot be referenced from the static context
[leetcode skimming] February summary (updating)
随机推荐
Common thread methods and daemon threads
[send email with error] 535 error:authentication failed
京东智能客服言犀意图体系搭建和意图识别技术介绍
Some small knowledge points
431. 将 N 叉树编码为二叉树 DFS
Knowledge supplement: basic usage of redis based on docker
Why can't you find the corresponding function by clicking go to definiton (super easy has a diagram)
熊市下的Coinbase:亏损、裁员、股价暴跌
How to ensure the idempotency of the high concurrency interface?
PageObject模式解析及案例
283. move zero
Analyse et cas du modèle pageobject
Use selenium automated test tool to climb the enrollment score line and ranking of colleges and universities related to the college entrance examination
LeetCode 1400. Construct K palindrome strings
NFT: start NFT royalty journey with eip-2981
TASK04|数理统计
Spock单元测试框架介绍及在美团优选的实践___第一章
Introduction of Spock unit test framework and its practice in meituan optimization___ Chapter I
Possible problems and solutions of using scroll view to implement slider view
389. find a difference