将完整的col-md-2屏幕的背景颜色设为黑色

时间:2016-11-09 19:03:35

标签: php html css twitter-bootstrap

This is what I tried to make This is what happened

我尝试制作简单的菜单,我的目标是让完整的col-md-2屏幕的背景颜色变黑(如图像-1),但是当文本/ radiobutton /等时。菜单结束,col-md-2的空屏幕的其余部分采用了正文的背景颜色(在图像-2中)而不是我的div的背景颜色。虽然我分别在我的身体背景颜色后面提到了<div>的背景颜色。这是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>ProductExchanger</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- ONLINE -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body style="color: white ; background-color: #2aabd2 ; ">

<!-- ONLINE -->
<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>


<div class="col-md-2" style="padding: 0 ;  background-color: #000000">
    <div class="container-fluid" style="background-color: darkmagenta">
        <h3>CATEGORY : </h3>
        <form>
            <div class="radio">
                <label><input type="radio" name="electronicsC">ELECTRONICS</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="vehiclesC">VEHICLES</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="furnitureC">FURNITURE</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="propertyC">PROPERTY</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="petsAndAnimalsC">PETS AND ANIMALS</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="hobbyAndSportsC">HOBBY AND SPORTS</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="foodAndAgriculture">FOOD AND AGRICULTURE</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="otherC">OTHER</label>
            </div>
        </form>
    </div>

    <div class="container-fluid" style="background-color: midnightblue ">
        <h3>DIVISION : </h3>
        <form>
            <div class="radio">
                <label><input type="radio" name="dhakaD">DHAKA</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="chittagongD">CHITTAGONG</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="rajshahiD">RAJSHAHI</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="rangpurD">RANGPUR</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="khulnaD">KHULNA</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="barisalD">BARISAL</label>
            </div>
            <div class="radio">
                <label><input type="radio" name="sylhetD">SYLHET</label>
            </div>
        </form>
    </div>
</div>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

<!DOCTYPE html>
<html>

  <head>
    <link data-require="bootstrap-css@3.3.6" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
    <style>
      .col-vh {
        background-color: #000;
        height: 100vh;
      }
    </style>
  </head>

  <body>
    <div class="container">
      <div class="row">
        <div class="col-md-2 col-vh">
          Lorem Ipsum
        </div>
      </div>
    </div>
  </body>

</html>

向列中添加100vh,它应该是视口的100%。 See this plunker

不同方法 在身体标签上使用最小高度和高度。 See this Question for details.