html5的导航标签怎么隐藏

发布时间:2022-05-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了html5的导航标签怎么隐藏脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

在htML5中,可以利用hidden属性隐藏导航标签,该属性的作用就是规定对指定的元素进行隐藏,该属性是html5中的新属性,语法为“<element hidden>”。

html5的导航标签怎么隐藏

本教程操作环境:windows10系统、HTML5版、Dell G3脑。

html5的导航标签怎么隐藏

在html5中想要隐藏导航标签,可以利用到hidden属性。

hidden 属性规定对元素进行隐藏。

隐藏的元素不会被显示。

如果使用该属性,则会隐藏元素。

可以对 hidden 属性进行设置,使用户在满足某些条件时才能看到某个元素(比如选中复选框,等等)。然后,可使用 JavaScript 来删除 hidden 属性,使该元素变得可见。

示例如下:

<!DOCTYPE html>
<html lang="en">
<head>
  <;meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, inITial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=Edge">
  <title>Document</title>
  <style type="text/css">
    *{margin:0;padding: 0;}
   ul{
       list-style-type: none;
       overflow: hidden;
       
       position: fixed;
       top: 0;
       width: 100%;
       
   }  
   li {
       float: left;
   }   
   li a {
       display: block;
       color: white;
       text-align: center;
       padding: 14px 16px;
       text-decoration: none;
   }   
   li a:hover{
       background-color: red;
   }   
</style>
</head>
<body>
<ul>
   <li hidden><a href="#home">首页</a></li>
   <li hidden><a href="#news">新闻动态</a></li>
   <li hidden><a href="#contact">联系我们</a></li>
   <li hidden><a href="#about">关于我们</a></li>
</ul>   
<div style="background-color:pink;height:1500px;"></div>
</body>
</html>

在没有给导航元素添加hidden属性时输出结果如下;

html5的导航标签怎么隐藏

给导航栏元素添加hidden属性后输出结果如下:

html5的导航标签怎么隐藏

推荐教程:《html视频教程》

以上就是html5的导航标签怎么隐藏的详细内容,更多请关注脚本宝典其它相关文章

脚本宝典总结

以上是脚本宝典为你收集整理的html5的导航标签怎么隐藏全部内容,希望文章能够帮你解决html5的导航标签怎么隐藏所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: