【无标题】

下拉菜单

----来自菜鸟教程
<style>
/* 下拉按钮样式 */
.dropbtn {
    background-color: #4CAF50;
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;  //改变鼠标形状
}

/* 容器 <div> - 需要定位下拉内容 */
.dropdown {
    position: relative;
    display: inline-block;
}

/* 下拉内容 (默认隐藏) */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

/* 下拉菜单的链接 */
.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

/* 鼠标移上去后修改下拉菜单链接颜色 */
.dropdown-content a:hover {background-color: #f1f1f1}

/* 在鼠标移上去后显示下拉菜单 */
.dropdown:hover .dropdown-content {
    display: block;
}

/* 当下拉内容显示后修改下拉按钮的背景颜色 */
.dropdown:hover .dropbtn {
    background-color: #3e8e41;
}
</style>

<div class="dropdown">
  <button class="dropbtn">下拉菜单</button>
  <div class="dropdown-content">
    <a href="#">菜鸟教程 1</a>
    <a href="#">菜鸟教程 2</a>
    <a href="#">菜鸟教程 3</a>
  </div>
</div>

结合上例自己做的下拉菜单,还未成功。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimun-scale=1.0, maxium-scale=1.0">
    <title>Document</title>
</head>
<style>
	/* 菜单键与关闭键的交换 */
.trans {
    position: absolute;
    left: 89%;
    right: 0%;
    bottom: 45%;
    float: auto;
    width: 40px;
    height: 40px;
    overflow: hidden;
}
.trans2 {
    position: absolute;
    left: 89%;
    right: 0%;
    bottom: 45%;
    float: auto;
    background: url(images/选项icon.png) no-repeat center;
}
.trans::before {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background: url(images/close.png) no-repeat center; 
    transform: rotate(180deg);
    transform-origin: left top;
    transition: all 0.2s ease;
}
.trans:hover::before {
    transform: rotate(0deg);
}
.trans2:hover {
    background: none;
}
/* 下拉菜单 */
.dropdown {
   display: inline-block;
}
.dropdown-content {
   display: none;
}
.dropdown:hover .dropdown-content {
   display: block;
   height: 664px;
   width: 100%;
   position: absolute;
   right: 0%;
   top: 100%;
   background-color: rgba(255, 255, 255, 0.8);
}
.dropdow::cue-region .dropdown-content {
   display: none;
}
.dropdown-content ul li {
   position: relative;
   font-family: 'Arial';
   font-style: normal;
   font-weight: 400;
   font-size: 36px;
   line-height: 41px;
   text-align: center;
   color: #000000;
   flex: none;
   order: 0;
   flex-grow: 0;
   margin: 60px 0px;
}
.dropdown-content ul li a {
   text-decoration: none;
   color: #000000;
}
.dropdown-content .search {
   position: absolute;
   border: none;
   outline: none;
   background: url(images/search.png) no-repeat center;
   right: 50%;
   top: 10%;
   height: 35px;
   width: 35px;
   margin-right: 40px;
}
.dropdown-content .memeber {
   position: absolute;
   border: none;
   outline: none;
   background: url(images/成员.png) no-repeat center;
   left: 50%;
   top: 10%;
   height: 35px;
   width: 35px; 
   margin-left: 50px;
}
.dropdown-content .language {
   position: absolute;
   background: url(images/language.png) no-repeat center;
   right: 50%;
   top: 60px;
   margin-right: 20px;
   height: 35px;
   width: 40px;
}
#lan {
   position: absolute;
   width: 96px;
   height: 35px;
   top: 60px;
   margin: 0 auto;
   font-size: 24px;
   line-height: 35px;
   color: #000000;
}
</style>
<body>
          <!-- 菜单键和关闭键和下拉菜单 -->
           <div class="dropdown">
               <button class="trans trans2"></button>
               <div class="dropdown-content">
                   <ul>
                       <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>
                       <li>
                           <button class="search"></button>
                           <button class="memeber"></button>
                       </li>
                       <li>
                           <span class="language"></span>
                           <span id="lan">简体中文</span>
                       </li>
                   </ul>
               </div>
           </div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值