整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:

css实现的动态导航菜单,倾斜放置,鼠标悬停回正ht

css实现的动态导航菜单,倾斜放置,鼠标悬停回正html前端源码

家好,今天给大家介绍一款,css实现的动态导航菜单,倾斜放置,鼠标悬停回正html页面前端源码(图1)。送给大家哦,获取方式在本文末尾。

图1

自带酷炫动画效果,支持多级菜单(图2)

图2

源码完整,需要的朋友可以下载学习(图2)

图2

本源码编码:20217,需要的朋友,访问下面链接后,搜索20217,即可获取。

就爱UI - 分享UI设计的点点滴滴




lt;!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>导航菜单</title>

<link rel="stylesheet" type="text/css" href="css/nav.css"/>

</head>

<body>

<!--头部-->

<header>

<div class="container">

<!--导航条-->

<ul class="nav">

<li style="background-color: gold;">

<a href="#">首页</a>

</li>

<li>

<a href="#">公司概况</a>

<ul class="nav-list">

<li>公司简介</li>

<li>发展历程</li>

<li>组织机构</li>

<li>总经理寄语</li>

</ul>

</li>

<li>

<a href="#">公司文化</a>

<ul class="nav-list">

<li>文化理念</li>

<li>员工活动</li>

<li>党/工/团建设</li>

</ul>

</li>

<li>

<a href="#">公司新闻</a>

</li>

<li>

<a href="#">服务内容</a>

</li>

<li>

<a href="#">法律政策</a>

</li>

<li>

<a href="#">人才招聘</a>

</li>

<li>

<a href="#">联系我们</a>

</li>

</ul>

</div>

</header>

</body>

</html>

nav.css

@charset "utf-8";

*{

margin: 0px;

padding: 0px;

}


<svg width="0" height="0">
			<defs>
				<filter id="goo">
					<feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
					<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 19 -9" result="goo" />
					<feComposite in="SourceGraphic" in2="goo" operator="atop" />
				</filter>
			</defs>
		</svg>
		<div class="target">
			<div>
				<i id="ball1" class="ball"></i>
				<i id="ball2" ref="ball2" class="ball"></i>
			</div>
		</div>
<div class="menu">
			<div class="menu-item" @click="updageMenuItem(0)">
				首页
				<span :class="{'menu-item-bg': menuActive==0}">
					<i class="iconfont"></i>
				</span>
			</div>
			<div class="menu-item" @click="updageMenuItem(1)">
				发现
				<span :class="{'menu-item-bg': menuActive==1}">
					<i class="iconfont"></i>
				</span>
			</div>
			<div class="menu-item" @click="updageMenuItem(2)">
				消息
				<span :class="{'menu-item-bg': menuActive==2}">
					<i class="iconfont"></i>
				</span>
			</div>
			<div class="menu-item" @click="updageMenuItem(3)">
				我的
				<span :class="{'menu-item-bg': menuActive==3}">
					<i class="iconfont"></i>
				</span>
			</div>
		</div>

<script>
updageMenuItem(index) {
			this.menuActive=index;
			let ball2=this.$refs.ball2;
			Array(4)
				.fill(0)
				.map((item, it)=> {
					ball2.classList.remove('active' + it);
				});
			setTimeout(()=>{
				ball2.classList.add('active' + index);
			},100)
		}
</script>

<style lang="less" scoped>
.profile {
	height: 100%;
	background: #aaaa7f;
	font-size: 14px;
	.menu,
	.target {
		position: absolute;
		bottom: 0;
		width: 100%;
		height: 50px;
		left: 0;
	}
	.target > div {
		filter: url('#goo');
	}
	.menu {
		display: flex;
		z-index: 5;
		background: #fff;
		.menu-item {
			flex: 1;
			color: #333;
			display: flex;
			justify-content: center;
			align-items: flex-end;
			padding-bottom: 10px;
			position: relative;
			span {
				position: absolute;
				height: 35px;
				width: 35px;
				background: #aaaa7f;
				border-radius: 50%;
				left: 0;
				right: 0;
				margin: auto;
				top: 0;
				opacity: 0;
				display: flex;
				align-items: center;
				justify-content: center;
				i {
					color: #fff;
					font-size: 20px;
				}
				&.menu-item-bg{
					animation: menuItemBg .5s .2s forwards;
				}
			}
		}
	}
	.ball {
		width: calc(100% + 60px);
		height: 50px;
		border-radius: 0;
		background-color: #fff;
		position: absolute;
		left: -30px;
		margin: auto;
		z-index: 1;
	}
	#ball2 {
		left: 0;
		top: 0px;
		width: 50px;
		height: 50px;
		margin: auto;
		border-radius: 50%;
		&.active0 {
			left: calc(((100% / 4) - 50px) / 2);
			animation: ballUp .5s forwards;
		}
		&.active1 {
			left: calc(((100% / 4) - 50px) / 2 + 100% / 4);
			animation: ballUp .5s forwards;
		}
		&.active2 {
			left: calc(((100% / 4) - 50px) / 2 + (100% / 4) * 2);
			animation: ballUp .5s forwards;
		}
		&.active3 {
			left: calc(((100% / 4) - 50px) / 2 + (100% / 4) * 3);
			animation: ballUp .5s forwards;
		}
	}
}
@keyframes ballUp {
	from {
		top: 0;
	}
	to {
		top: -25px;
	}
}
@keyframes menuItemBg {
	from {
		top: 0;
		opacity: 0;
	}
	to {
		top: -15px;
		opacity: 1;
	}
}