html - Bootstrap 在页面上不起作用

标签 html css twitter-bootstrap

我的 html 页面无法正常工作,但 bootstrap 应该可以使它像我想要的那样工作。我下载 bootstrap 并将 css 文件包含到带有来自 font-awesome page 的 font-awesome.min.css 的页面中。 .我还要确保我都写得正确。我看着安慰并发现我的文件没有包含在页面中。如果您有任何问题,可以在评论中问我。

这是我的代码:

@import url('https://fonts.googleapis.com/css?family=Lato|Raleway');
body {
  background-color: #f2f2f2;
  font-family: "Lato";
  font-weight: 300;
  font-size: 16px;
  color: #555;
  -webkit-font-smoothing: antialiased;
  -webkit-overflow-scrolling: touch;
  margin-top: 60px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: Raleway;
  font-weight: 300;
  color: #333;
}

p {
  line-height: 28px;
  margin-bottom: 25px;
}

.centered {
  text-align: center;
}

a {
  color: #f85c37;
}

a:hover,
a:focus {
  color: #7b7b7b;
  text-decoration: none;
  outline: 0;
}

hr {
  display: block;
  height: 1px;
  border: 0px;
  border-top: 1px solid #ccc;
  margin: 1em 0;
  padding: 0;
}

.navbar {
  font-weight: 800;
  fin-sise: 14px;
  padding-top: 15px;
  padding-bottom: 15px;
}

.navbar-inverse {
  background: #2d2d2d;
  border-color: #2d2d2d;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Bootstrap сайт</title>
  <link rel="stylesheet" href="css/bootstrap.css">
  <link rel="stylesheet" href="css/font-awesome.min.css">
  <link rel="stylesheet" href="css/stylesheet.css">
</head>

<body>
  <div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
        <a class="navbar-brand" href="#">PR<i class="fa fa-circle"></i>GER</a>
      </div>
      <div class="navbar-collapse collapse">
        <!--class="navbar-collapse collapse"-->
        <ul class="nav navbar-nav navbar-right">
          <li class="active"><a href="#">Домой</a></li>
          <li><a href="#">Про нас</a></li>
          <li><a href="#">Сервсиы</a></li>
          <li><a href="#">Работы</a></li>
          <li><a href="#"><i class="fa fa-envelope-o" aria-hidden="true"></i></a></li>
        </ul>
      </div>
    </div>
  </div>
</body>

</html>

最佳答案

文档中缺少一些重要的标签。全部为您解决:

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head -->
    <title>Bootstrap 101 Template</title>
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/stylesheet.css">
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
</head>

<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">PR<i class="fa fa-circle"></i>GER</a>
            </div>
            <div class="navbar-collapse collapse">
                <!--class="navbar-collapse collapse"-->
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="#">Домой</a></li>
                    <li><a href="#">Про нас</a></li>
                    <li><a href="#">Сервсиы</a></li>
                    <li><a href="#">Работы</a></li>
                    <li><a href="#"><i class="fa fa-envelope-o" aria-hidden="true"></i></a></li>
                </ul>
            </div>
        </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
</body>

</html>

关于html - Bootstrap 在页面上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45936555/

相关文章:

php - 如何在全宽woocommerce中显示单品页面?

html - 分享按钮 - 悬停和 Googleplus/Facebook 链接

html - div 周围缺少灰色背景,按钮上缺少橙色背景

css - 如何在 CSS HTML5 中将表格居中对齐?

jquery - 如何使用 jquery 更改 div 填充百分比?

html - "Non-responsive usage of Bootstrap"是什么意思?

css - 嵌套元素中的每 2n 个元素

php - 将 php 页面连接到 mySql

javascript - 如何跟踪 jQuery 拖放功能

javascript - 解析在 Angular ui 模式中不起作用