当前位置:网站首页>(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 !
边栏推荐
- 【TA-霜狼_may-《百人计划》】1.2.1 向量基础
- 跳槽一次涨8k,5年跳了3次...
- 25.K个一组翻转链表
- "Target detection" + "visual understanding" realizes the understanding of the input image
- Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
- 小程序中自定义组件
- Valid @suppresswarnings warning name
- ThreeJS开篇
- JMeter学习笔记2-图形界面简单介绍
- Class and object finalization
猜你喜欢

Task04 | statistiques mathématiques

采购数智化爆发在即,支出宝'3+2'体系助力企业打造核心竞争优势

In the innovation community, the "100 cities Tour" of the gold warehouse of the National People's Congress of 2022 was launched

Unity's 3D multi-point arrow navigation

【TA-霜狼_may-《百人计划》】1.2.1 向量基础
![[TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation](/img/49/173b1f1f379faa28c503165a300ce0.png)
[TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation

ThreeJS开篇

The programmer's girlfriend gave me a fatigue driving test

【TA-霜狼_may-《百人计划》】2.2 模型与材质空间

Tip of edge browser: enter+ctrl can automatically convert the address bar into a web address
随机推荐
[recommended algorithm] C interview question of a small factory
[untitled]
MFC window scroll bar usage
Embedded System Development Notes 80: using QT designer to design the main interface
JMeter学习笔记2-图形界面简单介绍
Edge浏览器的小技巧:Enter+Ctrl可以自动将地址栏转换为网址
[EI conference] the Third International Conference on nanomaterials and nanotechnology in 2022 (nanomt 2022)
HoloLens2开发环境搭建及部署app
Use of JMeter counters
Task04 mathematical statistics
TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.2 多属性注册协议(Multiple Registration Protocol (MRP))
Unity's 3D multi-point arrow navigation
Mallbook: how can hotel enterprises break the situation in the post epidemic era?
做网站数据采集,怎么选择合适的服务器呢?
392. judgment subsequence
What is uid? What is auth? What is a verifier?
MySQL function variable stored procedure
Threejs opening
After many job hopping, the monthly salary is equal to the annual salary of old colleagues
What are permissions? What are roles? What are users?