如何制作一个不固定的透明导航栏?

时间:2017-01-27 19:46:37

标签: css twitter-bootstrap web responsive-design

我想在Bootstrap中制作透明导航栏,它不是固定顶部但我无法使用Bootstrap。我应该使用纯CSS制作它还是我可以使用Bootstrap找到另一个选项?

2 个答案:

答案 0 :(得分:0)

尝试下面的代码段



.navbar-default{
  background-color: transparent !important;
}

   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body style="background-color: #5cb85c;">
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
    	<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
        	 <span class="icon-bar"></span>
       		 <span class="icon-bar"></span>
       		 <span class="icon-bar"></span>                        
      	</button>
      <a class="navbar-brand" href="/"><i class="fa fa-code"></i> TC</a>
    </div>
   <div class="collapse navbar-collapse" id="navbar">
    <ul class="nav navbar-nav">
      <li class="active"><a href="/" class="home">Home</a></li>
      <li><a href="templates" class="templates">Page 2</a></li>
    </ul>
  </div>
 </div>
</nav>
</body>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

<nav class="navbar navbar-default">

只需删除navbar-fixed-top

即可

然后使用CSS使其透明

.navbar-default {background-color:transparent}