BOOTSTRAP导航栏的样式不起作用

时间:2017-03-19 11:54:57

标签: twitter-bootstrap-3

我使用bootstrap在类jumbotron中创建了一个导航栏。但似乎导航栏菜单存在一些问题。 “li”标签中没有填充或样式。所有li标签只是以下列方式粘在一起: HOMEPRICEGALLERYMEDIAFAQs联系我们

<!DOCTYPE html>
<html lang="en">
<head>
  <title>TATTOO</title>
    <meta charset="utf-8">
    <meta class="viewport" content="width=device-width, initial-scale=1">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    

    <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" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  
</head>
<body>
<!--create a header first using jumbotron class or header tricks-->
<div class="jumbotron" id="header">
  <img src="#">here comes the image</img>
  <!-- adding the navigtion bar  -->
  <nav class="navbar navbar-default">
    <div class="container">
      <ul class="nav navbar-nav">
        <li>HOME</li>
        <li>PRICE</li>
        <li>GALLERY</li>
        <li>MEDIA</li>
        <li>FAQs</li>
        <li>CONTACT US</li>
      </ul>  
    </div>
  </nav>
 </body>

2 个答案:

答案 0 :(得分:2)

您忘记将a tags添加到li标签中。这个标签负责填充 -

.navbar-nav>li>a {
padding-top: 15px;
padding-bottom: 15px;
}

<!DOCTYPE html>
<html lang="en">
<head>
  <title>TATTOO</title>
    <meta charset="utf-8">
    <meta class="viewport" content="width=device-width, initial-scale=1">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    

    <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" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  
</head>
<body>
<!--create a header first using jumbotron class or header tricks-->
   
   
 <div class="jumbotron" id="header">
      <img src="#">
      
      <!-- adding the navigtion bar  -->
      <nav class="navbar navbar-default">
        <div class="container">
          <ul class="nav navbar-nav">
            <li><a href="#">HOME</a></li>
            <li><a href="#">PRICE</a></li>
            <li><a href="#">GALLERY</a></li>
            <li><a href="#">MEDIA</a></li>
            <li><a href="#">FAQs</a></li>
            <li><a href="#">CONTACT US</a></li>
          </ul>  
        </div>
      </nav>
      </div>
     </body>
 </body>

答案 1 :(得分:2)

如果你将文本包装在锚标签中的列表项中,你会看到它的样式:)让我知道它是否有效

        <ul class="nav navbar-nav">
            <li><a href='#'>HOME </a></li>
            <li><a href='#'>PRICE </a></li>
            <li><a href='#'>GALLERY </a></li>
            <li><a href='#'>MEDIA </a></li>
            <li><a href='#'>FAQs </a></li>
            <li><a href='#'>CONTACT US </a></li>
        </ul>