web实训总结(3.26)

1. 编写导航栏的二级菜单

编写代码:
方法一(ul li ):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        *{  margin: 0;padding: 0;  }
        #nav{background-color: #050201;width: 600px;height: 40px;margin: 0 auto}
        ul li{list-style: none;float: left;line-height: 40px;text-align: center;position: relative}
        a{text-decoration: none;color: white;padding: 0 20px;display: block}
        a:hover{background-color: #ff0502;color: white; }
        ul li ul{position: absolute;top: 40px;left: 0;}
        ul li ul li{float: none;background-color: #050205;margin: 1px 0;display: none;}
        ul li ul li a{padding: 0;}
        ul li:hover ul li{display: block}
    </style>
</head>
<body>
<div id="nav">
    <ul>
        <li><a href="#">首页</a></li>
        <li><a href="#">课程大厅</a>
  <ul>
      <li><a href="#">web实战</a>
      <ul>
          <li><a href="#">大哥</a></li>
          <li><a href="#">二哥</a></li>
          <li><a href="#">三哥</a></li>
      </ul>
      </li>
      <li><a href="#">服务端技术</a></li>
      <li><a href="#">python开发</a></li>
  </ul>
  </li>
        <li><a href="#">学习中心</a></li>
        <li><a href="#">经典案例</a></li>
        <li><a href="#">关于我们</a></li>
    </ul>
</div>
</body>
</html>>

最终效果:
在这里插入图片描述

方法二(js):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        *{margin: 0; padding: 0}
        #nav{  background-color: darkgrey;  width: 600px; height: 40px;  margin: 0 auto;}
        ul{list-style: none}
        ul li{float: left; line-height: 40px; text-align: center;position: relative}
        a{ text-decortion:none;  color: #0099cc; display: block;padding:0 10px;}
        a:hover{background-color: #99cc00;color: #edcc61}
        ul li ul li{float: none;background-color: #edcc61;margin-top: 2px}
        ul li ul{position: absolute;left: 0px;  top: 40px; display: none}
        ul li ul li a:hover{background-color: #9933cc;}
        ul li:hover ul{display: block}
    </style>
</head>
<body>
<div id="nav">
    <ul>
        <li><a href="#">首页</a><>
        <li><a href="#">课程大厅</a>
            <ul>
                <li><a href="#">python</a><>
            </ul>
        <>
        <li><a href="#">学习中心</a><>
        <li><a href="#">经典案例</a><>
        <li><a href="#">关于我们</a><>
    </ul>
</div>
</body>
<ml>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值