使用CSS3动画制作导航菜单

使用CSS3动画制作导航菜单

1、使用定位属性把图片“赚”和“花”设置到相对应的位置上
2、使用animation属性给中间的“赚”和“花”图片设置动画,动画效果为鼠标移入“赚”图片的时候变为“赚积分”,
并且是从左到右缓慢展开的效 果
3、使用transition属性给右边的“论”图片设置动画,效果为鼠标移入旋转360°

效果展示在这里插入图片描述

代码展示

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>实验7_彩贝导航</title>
		<style>
			a{
				text-decoration: none;
			}
			.caibei{
				width: 100%;
				height: 100px;
				background-color: #eeeeee;
				line-height: 100px;
			}
			.logo{
				float: left;
			}
			li{
				/* position: relative; */
				float: left;
				list-style: none;
				width: 90px;
				cursor: pointer;
			}
			li a{
				margin-right: 10px;
				color: black;
			}
			li a:hover{
				color: #ff0000;
			}
			.right img{
				margin-left: 20px;
				cursor: pointer;
				transition: all 0.5s ease-in-out;
			}
			.right img:hover{
				transform: scale(1.5)rotate(360deg);
			}
			.icon1,
			.icon2{
				position: absolute;
				display: inline-block;
				width: 38px;
				height: 23px;
				top: 35px;
			}
			.icon1{
				background: url("./实验素材/header_03.png") 0 0 no-repeat;
			}
			.icon2{
				background: url("./实验素材/header_07.png") 0 0 no-repeat;
			}
			.back:hover .icon1{
				animation: zhuan 1s forwards;
			}
			.shop:hover .icon2{
				animation: hua 1s forwards;
			}
			@keyframes zhuan {
				0%{
					width: 37px;
					background: url("./实验素材/header_03.png") 0 0 no-repeat ;
				}
				30%{
					width: 45px;
					background: url("./实验素材/header_03.png") 0 0 no-repeat;
				}
				70%{
					width: 55px;
					background: url("./实验素材/header_03.png") 0 0 no-repeat;
				}
				100%{
					width: 65px;
					background: url("./实验素材/header_05.png") 0 0 no-repeat;
				}
			}
			@keyframes hua {
				0%{
					width: 37px;
					background: url("./实验素材/header_07.png") 0 0 no-repeat;
				}
				30%{
					width: 45px;
					background: url("./实验素材/header_07.png") 0 0 no-repeat;
				}
				70%{
					width: 55px;
					background: url("./实验素材/header_07.png") 0 0 no-repeat;
				}
				100%{
					width: 65px;
					background: url("./实验素材/header_09.png") 0 0 no-repeat;
				}
			}
		</style>
	</head>
	<body>
		<div class="caibei">
			<div class="logo">
				<img src="./实验素材/logo_170x46.png" alt="彩贝导航">
			</div>
			<nav>
				<ul>
					<li class="back">
						<a href="#">
							<span class="icon1"></span>
							返回商城
						</a>|
					</li>
					<li><a href="#">商旅频道</a>|</li>
					<li class="shop">
						<a href="#">
							<span class="icon2"></span>
							积分商城
						</a>|
					</li>
					<li><a href="#">商旅频道</a>|</li>
					<li><a href="#">了解彩贝</a>|</li>
					<li><a href="#">彩贝活动</a>|</li>
					<li><a href="#">个人中心</a>|</li>
				</ul>
			</nav>
			<div class="right">
				<img src="./实验素材/iconsB_11.gif" alt="">
				<img src="./实验素材/iconsB_12.gif" alt="">
				<img src="./实验素材/iconsB_13.png" alt="">
			</div>
		</div>
	</body>
</html>
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无良小老板

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值