css怎么实现横向导航和竖向导航栏
更新:HHH   时间:2023-1-7


小编给大家分享一下css怎么实现横向导航和竖向导航栏,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

  一、竖向导航

  <!DOCTYPEhtml>

  <html>

  <head>

  <metacharset="utf-8">

  <style>

  ul{

  list-style-type:none;

  margin:0;

  padding:0;

  }

  a{

  display:block;

  background-color:green;

  color:white;

  width:80px;

  text-align:center;

  padding:4px;

  text-decoration:none;

  }

  a:hover,a:active{

  background-color:#98bf21;

  }

  </style>

  </head>

  <body>

  <ul>

  <li><aherf="">首页</a></li>

  <li><aherf="">学习中心</a></li>

  <li><aherf="">考试中心</a></li>

  <li><aherf="">考试动态</a></li>

  </ul>

  </body>

  </html>

  运行结果:

  2345截图20180821104848.png

  二、横向导航:

  <!DOCTYPEhtml>

  <html>

  <head>

  <metacharset="utf-8">

  <style>

  ul{

  list-style-type:none;

  margin:0;

  padding:0;

  overflow:hidden;

  }

  li{

  float:left;

  }

  a{

  display:block;

  background-color:pink;

  color:white;

  width:80px;

  text-align:center;

  padding:4px0px;

  text-decoration:none;

  }

  a:hover,a:active{

  background-color:gray;

  }

  </style>

  </head>

  <body>

  <ul>

  <li><aherf="">首页</a></li>

  <li><aherf="">学习中心</a></li>

  <li><aherf="">考试中心</a></li>

  <li><aherf="">考试动态</a></li>

  </ul>

  </body>

  </html>




以上是“css怎么实现横向导航和竖向导航栏”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注天达云行业资讯频道!

返回web开发教程...