css3动画导航实现

时间:2024-01-14 22:10:08

代码

 <!DOCTYPE html>
<!-- saved from url=(0223)file:///C:/Users/user/AppData/Local/Temp/HZ$D.187.4185/HZ$D.187.4186/%E7%BE%A4%E5%8F%8B%E5%88%86%E4%BA%AB%E6%95%88%E6%9E%9C%E9%9B%86%E5%90%88/%E4%B8%80%E5%8F%B7%E5%88%86%E4%BA%ABcss3%E6%BB%91%E5%8A%A8%E5%AF%BC%E8%88%AA.html -->
<html lang="en"><!-- 申明当前页面--><!-- 头部--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--声明当前页面的编码格式 UTF-8(国际编码)gbk(中文简体)-->
<meta charset="UTF-8">
<!--声明当前页面的三要素-->
<title>css3动画导航效果</title>
<title></title>
<meta name="Keywords" content="关键字">
<meta name="Description" content="描述">
<!--样式 css 变漂亮 -->
<style type="text/css">
.menu { width: 900px;/*宽度*/ margin: 120px auto 0px auto; /*自适应浏览器居中*/ position: relative; }
.menu .current { position: absolute;/*定位*/ bottom: 0px; background: #dddddd; height: 2px; width: 100%; }
.nav { height: 50px;/*高度*/ /*background:#00cc99;背景颜色*/ }
.nav a { position: relative; z-index: 9999;/*当前所在位置*/ color: #666666;/*文字颜色*/ text-decoration: none; /*去除下划线*/ display: block;/*行元素转为块元素*/ float: left;/*浮动*/ height: 50px; line-height: 50px;/*文字垂直*/ padding: 0px 40px;/*内边距改变自身宽度*/ font-family: "微软雅黑"; font-size: 16px;/*文字字体 大小*/ overflow: hidden;/*超出去范围隐藏*/ }
.nav a .bor { background: #80b600; height: 2px; width: 100%; position: absolute; left: 0px; bottom: 0px; transform: translateX(-100%); -ms-transform:translateX(-100%); -o-transform:translateX(-100%); -moz-transform:translateX(-100%); -webkit-transform:translateX(-100%); /*css3改变当前位置*/ }
.nav a:hover { color: #80b600; }
.nav a:hover .bor { transform: translateX(0%); -ms-transform:translateX(0%); -o-transform:translateX(0%); -moz-transform:translateX(0%); -webkit-transform:translateX(0%); transition: all 800ms ease; -moz-transition: all 800ms ease; -o-transition: all 800ms ease; -webkit-transition: all 800ms ease;/*动画过程*/ }
.nav a.abcd { color: #80b600; }
.nav a.abcd .bor { transform: translateX(0%); -ms-transform:translateX(0%); -o-transform:translateX(0%); -moz-transform:translateX(0%); -webkit-transform:translateX(0%); } </style>
</head>
<!-- 身体-->
<body>
<!--div 盒子模型 容器 可以为他设置高度 宽度 放内容 -->
<div class="menu">
<div class="nav"> <a href="http://www.baidu.com/">首页
<div class="bor"></div>
</a> <a href="file:///C:/Users/user/AppData/Local/Temp/HZ$D.187.4185/HZ$D.187.4186/%E7%BE%A4%E5%8F%8B%E5%88%86%E4%BA%AB%E6%95%88%E6%9E%9C%E9%9B%86%E5%90%88/%E4%B8%80%E5%8F%B7%E5%88%86%E4%BA%ABcss3%E6%BB%91%E5%8A%A8%E5%AF%BC%E8%88%AA.html#">了解我们
<div class="bor"></div>
</a> <a href="file:///C:/Users/user/AppData/Local/Temp/HZ$D.187.4185/HZ$D.187.4186/%E7%BE%A4%E5%8F%8B%E5%88%86%E4%BA%AB%E6%95%88%E6%9E%9C%E9%9B%86%E5%90%88/%E4%B8%80%E5%8F%B7%E5%88%86%E4%BA%ABcss3%E6%BB%91%E5%8A%A8%E5%AF%BC%E8%88%AA.html#">产品展示
<div class="bor"></div>
</a> <a href="file:///C:/Users/user/AppData/Local/Temp/HZ$D.187.4185/HZ$D.187.4186/%E7%BE%A4%E5%8F%8B%E5%88%86%E4%BA%AB%E6%95%88%E6%9E%9C%E9%9B%86%E5%90%88/%E4%B8%80%E5%8F%B7%E5%88%86%E4%BA%ABcss3%E6%BB%91%E5%8A%A8%E5%AF%BC%E8%88%AA.html#">服务报价
<div class="bor"></div>
</a> <a href="file:///C:/Users/user/AppData/Local/Temp/HZ$D.187.4185/HZ$D.187.4186/%E7%BE%A4%E5%8F%8B%E5%88%86%E4%BA%AB%E6%95%88%E6%9E%9C%E9%9B%86%E5%90%88/%E4%B8%80%E5%8F%B7%E5%88%86%E4%BA%ABcss3%E6%BB%91%E5%8A%A8%E5%AF%BC%E8%88%AA.html#">最新消息
<div class="bor"></div>
</a> <a href="file:///C:/Users/user/AppData/Local/Temp/HZ$D.187.4185/HZ$D.187.4186/%E7%BE%A4%E5%8F%8B%E5%88%86%E4%BA%AB%E6%95%88%E6%9E%9C%E9%9B%86%E5%90%88/%E4%B8%80%E5%8F%B7%E5%88%86%E4%BA%ABcss3%E6%BB%91%E5%8A%A8%E5%AF%BC%E8%88%AA.html#">联系方式
<div class="bor"></div>
</a> </div>
<div class="current"></div>
</div> </body></html>

效果展示

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABB8AAADDCAIAAABF6S64AAAM7UlEQVR4nO3dMVLjPB8HYA61Z8pwhlTcIO/M3oDcgIJxQ7VDSZUCKL5yz+GvwIklW3Js+O/Lu/bzDMWS2ElWimz9LMnctAAAABFuvvsDAAAAKyFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLAAAghnQBAADEkC4AAIAY0gUAABBDugAAAGJIFwAAQAzpAgAAiCFdAAAAMaQLA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