简体   繁体   English

背景色不变

[英]Background Color not changing bug

I cannot figure out where the bug is in this code. 我无法弄清楚该代码中的错误。 I'm trying to change the background color to anything using the following css: 我正在尝试使用以下CSS将背景颜色更改为任何颜色:

body {
background-color: black;
    padding: 0px;
    margin:0px; 
    height: 1500px;
}

But its not changing anything except shifting the navbar down a few rows for some reason. 但是除了出于某些原因将导航栏向下移动几行之外,它什么也没有改变。 Why is this happening and why can't I change the background color? 为什么会发生这种情况,为什么我不能更改背景颜色?

index.html index.html

<!doctype html>
<html>
<head> 
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href=""> <!--tab image-->
<title> Bear Patrol | Home </title>
<link rel="stylesheet" type="text/css" href="main.css">
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <a id="logo" href="index.html">BEAR PATROL</a>
    <ul class="nav navbar-nav navbar-right">
        <li><a href="index.html">HOME</a></li>       
        <li><a href="about.html">ABOUT US</a></li>
        <li><a href="contact.html">CONTACT</a></li>
    </ul>
</div><!-- /.navbar-collapse -->
<div>
    <div class="col-xs-8 col-xs-offset-2 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2 center hero-unit">
        <h1 id="name">BEAR PATROL</h1>
        <img id="mainPic" src="bp.jpg">
        <div id="bio">
            <h4>Late Night Escorts Anywhere On Campus</h4>
            <h4> Headquarters Located in Whispers </h4>
            <h4>Available 8 PM to 2 AM Every Day</h4>
        </div>
    </div>
</div>

<div id="contact" class="col-xs-8 col-xs-offset-2 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2 center hero-unit">
        <a href="contact.html"><h1> REQUEST AN ESCORT!</h1></a>

    </div>
</div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- js -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

main.css main.css

body {
    padding: 0px;
    margin:0px; 
    height: 1500px;
    background-color: black;
}

#img {
    text-align: center;
    height: 300px;
    width: 230px;
}

#mainPic {
    text-align: center;
    height: 300px;
    width: 500px;
    margin: 50px;
}

form {
    margin-left: 176px;
    margin-top: 30px;
}

#title {
    padding-top: 105px;
    text-align: center;
    margin-top: 0px;
    color: white;
    font-size: 60px;
    font-family: helvetica;
}

#logo {
    font-size: 20px;
    font-style: bold;
    margin-top: 28px;
    margin-left: 20px;
    display: inline-block;
    border-style: solid;
    border-width: 5px;
    padding: 10px;
}

#info {
    text-align: center;
    padding-top: 20px;
    color: white;
    font-size: 68px;
    font-family: helvetica; 
}

.hero-input {
    padding: 5px;
    margin: 5px;
    display:inline-block;
}

#navbar-nav {
    padding-left: 150px;
}

#contact {
    opacity: .9;
}

#button {
    background-color: blue;
    float: right;
}

#nav {
    margin-top: 9px;
    margin-right: 20px;
    display: inline-block;
}

.hero-unit {
    text-align: center;
    background-color: blue;
    font-size: 11px;
    margin: 30px;
    padding: 30px;
    line-height: 1.4em;
    -webkit-border-radius: 5px; 
    -moz-border-radius: 5px; 
    border-radius: 5px; 
    box-shadow: 1px 1px 10px #444;
    border-color: #C1C1C1;
    color: white; 
}

li {
    list-style-type: none;
    margin-top: 15px;
    margin-right: 12px;
    display: inline-block;
    font-size: 15px;
    /* color: white; */
}

a:link, a:visited, a:active {
    color: black;
}

a:hover {
    color: blue;
}

::-webkit-input-placeholder {
   font-family: helvetica;
   line-height: 1.8;
   font-size: 12px;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1;
}

h1 {
  font-size: 3em;
  letter-spacing: 4px;
  margin-bottom: 30px;
  text-align: center;
}

h4 {
  font-size: 2em;
  letter-spacing: -1px;
  margin-bottom: 30px;
  text-align: center;
  font-weight: normal;
}

p {
  font-size: 1.1em;
  line-height: 1.7em;
}

Change the css link order like below 更改CSS链接顺序,如下所示

<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="main.css">

is working fine http://jsfiddle.net/gtpco6k9/ 工作正常http://jsfiddle.net/gtpco6k9/

in same selector , main.css will overwrite bootstrap.min.css 在同一选择器中, main.css将覆盖bootstrap.min.css

about css priority order, check out this post -> here 关于CSS优先顺序,请查看此帖子-> 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM