充分COL-MD-2屏幕的背景颜色黑色

问题描述:

This is what I tried to make This is what happened充分COL-MD-2屏幕的背景颜色黑色

我试图让简单的菜单,我的目标是充分col-md-2屏幕的背景颜色黑色(如图片 - 1),但是当文本/单选按钮/等。的菜单结束,col-md-2的空屏幕的其余部分采用了body的背景色(在图像-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> 

<!DOCTYPE html> 
<html> 

    <head> 
    <link data-require="[email protected]" 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.

+0

非常感谢,它的工作原理,也适用于外部问题链接 – 000