欢迎光临散文网 会员登陆 & 注册

01-简单的导航栏(html+css)

2022-10-05 10:01 作者:爱前端的时迁酱  | 我要投稿

《01-简单的导航栏(html+css)》

代码如下:

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3.   <head>
  4.     <meta charset="UTF-8" />
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7.     <title>简单的导航栏</title>
  8.     <style>
  9.       * {
  10.         margin: 0;
  11.         padding: 0;
  12.       }
  13.       body {
  14.         background-color: #f1b8e4;
  15.         width: 100vw;
  16.         height: 100vh;
  17.       }
  18.       nav{
  19.         position: fixed;
  20.         top: 0;
  21.         left: 0;
  22.         width: 100%;
  23.         height: auto;
  24.         background-color: #fec433;
  25.         display: flex;
  26.         align-items: center;
  27.         justify-content: center;
  28.       }
  29.       .navbody{
  30.         /* border:1px red solid; */
  31.         margin: 0 10px;
  32.         width: 1200px;
  33.         height: 64px;
  34.         display: flex;
  35.         align-items: center;

  36.       }
  37.       img{
  38.         width: 100px;
  39.         height: 50%;
  40.       }
  41.       .navbody > ul{
  42.         display: flex;
  43.         width: calc(100% - 100px);
  44.         height: 100%;
  45.         justify-content: center;
  46.         align-items: center;
  47.       }
  48.       .navbody > ul > li{
  49.         margin: 5px;
  50.         font-weight: 500;
  51.         list-style: none;
  52.         color: aliceblue;
  53.         font-size: 22px;
  54.         height: 100%;
  55.         flex: 1;
  56.         text-align: center;
  57.         line-height: 64px;
  58.         /* 居中 */
  59.         /* transition: all .3s; */
  60.       }
  61.       .navbody > ul > li:hover{
  62.         opacity: 1;
  63.         background-color: #f6b206;
  64.       }
  65.     </style>
  66.   </head>
  67.   <body>
  68.     <nav>
  69.       <div class="navbody">
  70.         <!-- logo -->
  71.         <img src="./img/logo.svg" alt="logo" class="img">
  72.         <ul>
  73.           <li>导航1</li>
  74.           <li>导航2</li>
  75.           <li>导航3</li>
  76.           <li>导航4</li>
  77.           <li>导航5</li>
  78.         </ul>
  79.       </div>
  80.     </nav>
  81.   </body>
  82. </html>


github开源链接:https://github.com/timeshiftsauce/day

预览链接:https://timeshiftsauce.github.io/day/1-DAY.HTML

01-简单的导航栏(html+css)的评论 (共 条)

分享到微博请遵守国家法律