CSS3多级联动菜单

CSS3实现的多级联动菜单

预览



<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>HTML5 CSS3下拉导航菜单</title>
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background-color: #1e1e1e;
  background-size: cover;
  height: 100vh;
  font-family: "Raleway", sans-serif;
  letter-spacing: 1px;
}
h1 {
  text-align: center;
  color: #fff;
  padding-top: 20px;
}
ul {
  list-style: none;
}
nav {
  height: 40px;
  margin: 40px auto;
  background-color: rgba(23, 23, 50, 0.7);
  text-align: center;
  border-radius: 4px;
}
.main {
  display: flex;
  justify-content: center;
}
.main > li {
  margin: 0 2%;
}
.main > li a{
  border-left:1px solid rgba(23, 23, 50, 1);
}
a {
  text-decoration: none;
  color: #ffe;
  text-transform: capitalize;
  font-family: monospace;
  display: block;
  padding: 10px 15px;
  font-size: 16px;
  transition: background-color 0.5s ease-in-out;
  font-family: "Raleway", sans-serif;
}
a:hover {
  background-color: #631818;
}
.drop li {
  opacity: 0;
  transform-origin: top center;
}
.drop li a {
  background-color: rgba(23, 23, 50, 0.7);
  padding: 10px 0;
}
/*------------- menu1 animation -------------------*/
.main li:hover .menu1 li:first-of-type {
  animation: menu1 0.3s ease-in-out forwards;
  animation-delay: 0.3s;
}
.main li:hover .menu1 li:nth-of-type(2) {
  animation: menu1 0.3s ease-in-out forwards;
  animation-delay: 0.6s;
}
.main li:hover .menu1 li:nth-of-type(3) {
  animation: menu1 0.3s ease-in-out forwards;
  animation-delay: 0.9s;
}
.main li:hover .menu1 li:last-of-type {
  animation: menu1 0.3s ease-in-out forwards;
  animation-delay: 1.2s;
}
@keyframes menu1 {
  from {
    opacity: 0;
    transform: translateX(30px) rotateY(90deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
  }
}
/*------------- menu2 animation -------------------*/
.main li:hover .menu2 li:first-of-type {
  animation: menu2 0.3s ease-in-out forwards;
  animation-delay: 0.3s;
}
.main li:hover .menu2 li:nth-of-type(2) {
  animation: menu2 0.3s ease-in-out forwards;
  animation-delay: 0.6s;
}
.main li:hover .menu2 li:nth-of-type(3) {
  animation: menu2 0.3s ease-in-out forwards;
  animation-delay: 0.9s;
}
.main li:hover .menu2 li:last-of-type {
  animation: menu2 0.3s ease-in-out forwards;
  animation-delay: 1.2s;
}
@keyframes menu2 {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
/*------------- menu3 animation -------------------*/
.main li:hover .menu3 li:first-of-type {
  animation: menu3 0.3s ease-in-out forwards;
  animation-delay: 0.3s;
}
.main li:hover .menu3 li:nth-of-type(2) {
  animation: menu3 0.3s ease-in-out forwards;
  animation-delay: 0.6s;
}
.main li:hover .menu3 li:nth-of-type(3) {
  animation: menu3 0.3s ease-in-out forwards;
  animation-delay: 0.9s;
}
.main li:hover .menu3 li:last-of-type {
  animation: menu3 0.3s ease-in-out forwards;
  animation-delay: 1.2s;
}
@keyframes menu3 {
  0% {
    opacity: 0;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}
/*------------- menu4 animation -------------------*/
.main li:hover .menu4 li:first-of-type {
  animation: menu4 0.3s ease-in-out forwards;
  animation-delay: 0.3s;
}
.main li:hover .menu4 li:nth-of-type(2) {
  animation: menu4 0.3s ease-in-out forwards;
  animation-delay: 0.6s;
}
.main li:hover .menu4 li:nth-of-type(3) {
  animation: menu4 0.3s ease-in-out forwards;
  animation-delay: 0.9s;
}
.main li:hover .menu4 li:last-of-type {
  animation: menu4 0.3s ease-in-out forwards;
  animation-delay: 1.2s;
}
@keyframes menu4 {
  0% {
    opacity: 0;
    transform: translateX(50px) rotate(-90deg);
  }
  100% {
    opacity: 1;
    transform: translateX(0) rotate(0);
  }
}
/*------------- menu5 animation -------------------*/
.main li:hover .menu5 li:first-of-type {
  animation: menu5 0.3s ease-in-out forwards;
  animation-delay: 0.3s;
}
.main li:hover .menu5 li:nth-of-type(2) {
  animation: menu5 0.3s ease-in-out forwards;
  animation-delay: 0.6s;
}
.main li:hover .menu5 li:nth-of-type(3) {
  animation: menu5 0.3s ease-in-out forwards;
  animation-delay: 0.9s;
}
.main li:hover .menu5 li:last-of-type {
  animation: menu5 0.3s ease-in-out forwards;
  animation-delay: 1.2s;
}
@keyframes menu5 {
  0% {
    opacity: 0;
    transform: rotateX(-90deg);
  }
  100% {
    opacity: 1;
    transform: rotateX(0);
  }
}
/*------------- menu6 animation -------------------*/
.main li:hover .menu6 li:first-of-type {
  animation: menu6 0.3s ease-in-out forwards;
  animation-delay: 0.2s;
}
.main li:hover .menu6 li:nth-of-type(2) {
  animation: menu6 0.3s ease-in-out forwards;
  animation-delay: 0.4s;
}
.main li:hover .menu6 li:nth-of-type(3) {
  animation: menu6 0.3s ease-in-out forwards;
  animation-delay: 0.6s;
}
.main li:hover .menu6 li:last-of-type {
  animation: menu6 0.3s ease-in-out forwards;
  animation-delay: 0.8s;
}
@keyframes menu6 {
  0% {
    opacity: 0;
    transform: scale(2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
/* my button style */
.white-mode {
  text-decoration: none;
  padding: 7px 10px;
  background-color: #122;
  border-radius: 3px;
  color: #fff;
  transition: 0.35s ease-in-out;
  position: absolute;
  left: 15px;
  bottom: 15px;
  font-family: sans-serif;
}
.white-mode:hover {
  background-color: #fff;
  color: #122;
}
</style>
</head>
<body>
<h1>多级联动演示</h1>
<nav>
  <ul class="main">
    <li>
      <a href="#">主页</a>
      <ul class="drop menu1">
        <li><a href="#">通知</a></li>
        <li><a href="#">公告</a></li>
        <li><a href="#">最新资讯</a></li>
        <li><a href="#">最新排名</a></li>
      </ul>
    </li>
    <li><a href="#">新闻</a>
      <ul class="drop menu2">
        <li><a href="#">军事新闻</a></li>
        <li><a href="#">娱乐新闻</a></li>
        <li><a href="#">生活新闻</a></li>
        <li><a href="#">影视新闻</a></li>
      </ul>
    </li>
    <li><a href="#">工作团队</a>
      <ul class="drop menu3">
        <li><a href="#">团队介绍</a></li>
        <li><a href="#">团队成员</a></li>
        <li><a href="#">团队理念</a></li>
        <li><a href="#">成果展示</a></li>
      </ul>
    </li>
    <li><a href="#">关于我们</a>
      <ul class="drop menu4">
        <li><a href="#">公司简介</a></li>
        <li><a href="#">公司地址</a></li>
        <li><a href="#">发展历程</a></li>
        <li><a href="#">展望</a></li>
      </ul>
    </li>
    <li><a href="#">加入我们</a>
      <ul class="drop menu5">
        <li><a href="#">招聘职位</a></li>
        <li><a href="#">招贤纳士</a></li>
      </ul>
    </li>
 
  </ul>
</nav>
</body>
</html>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值