无法更改背景颜色,用于引导程序

时间:2016-04-13 14:39:24

标签: html css twitter-bootstrap

我正在尝试将背景颜色更改为黑色。但它不起作用。 这是我提供的.css参考链接的问题吗?背景图像工作得很好,但是当我想制作一个具有特定颜色的普通背景时,它总是呈现白色。

我甚至尝试添加!重要,"背景颜色:黑色!重要; ...但仍然没用。



<!DOCTYPE html>
<html lang="en">
<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; any other head content must come *after* these tags -->
  <title>Project Selector</title>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/annyang/1.1.0/annyang.min.js"></script>

  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
        integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"
        integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
  <style>


    body {
      position: relative;
    }

    #home {
      padding-top: 50px;
      height: 667px;
      background-color: black;
    }

    h1.h11 {
      position: relative;
      text-align: center;
      color: black;
      top: 250px;
    }

  </style>

</head>

<body>

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container-fluid">
    <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="projectf.html">Projects</a>
    </div>
    <div>
      <div class="navbar-collapse collapses">
        <ul class="nav navbar-nav">
          <li><a href="#home">Home</a></li>
          <li><a href="#search">Search</a></li>
          <li><a href="#LoT">List of topics</a></li>
          <li><a href="#tutorial">Tutorial</a></li>
          <li><a href="#about">About</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>

<div class="home">
  <div class="container-fluid">
    <h1 class="h11">Project Selection Interface</h1>

  </div>
</div>

<!-- JQUERY JS file -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
        integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
        crossorigin="anonymous"></script>

</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

您在CSS中使用的是ID,而不是在html中使用的类

违规代码

#home{
padding-top:50px;
height:667px;
background-color:black;

}

更正代码

.home{
padding-top:50px;
height:667px;
background-color:black;

}