Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在最大高度的情况下如何将背景色应用于整个div_Html_Background Color - Fatal编程技术网

Html 在最大高度的情况下如何将背景色应用于整个div

Html 在最大高度的情况下如何将背景色应用于整个div,html,background-color,Html,Background Color,如何在溢出情况下将背景色应用于整个div:自动 当前背景色仅应用于div.not a的某些部分 整个部门 .brd{ border:1px solid grey; height:auto; max-height: 200px; overflow:auto; } .content{ float: left; width:50%; } .back-clr{ background-color: red; } <div clas

如何在溢出情况下将背景色应用于整个div:自动 当前背景色仅应用于div.not a的某些部分 整个部门

.brd{
    border:1px solid grey;
    height:auto;
    max-height: 200px;
    overflow:auto;
  }
.content{
    float: left;
    width:50%;
}
 .back-clr{
    background-color: red;
 }


 <div class="container">
  <div class="row">
      <div class="col-md-8 brd">
        <div class="content" style="width:50%">
            test test test <br>
            test test test <br>
            test test test <br>
            test test test <br>
            test test test <br>
            test test test <br>
            test test test <br>
            test test test <br>
            test test test <br>
                            </div>       
        <div class="content back-clr">
            this is second div
        </div>  
      </div>          
    </div>
.brd{
边框:1px纯灰;
高度:自动;
最大高度:200px;
溢出:自动;
}
.内容{
浮动:左;
宽度:50%;
}
.back clr{
背景色:红色;
}
测试
测试
测试
测试
测试
测试
测试
测试
测试
这是第二组

如果我没弄错的话。。试试这个

<style>
  .brd {
    border: 1px solid grey;
  }

  .content {
    float: left;
    width: 50%;
  }

  .back-clr {
    background-color: red;
  }

  .scroll-hold {
    overflow: auto;
    max-height: 200px;
  }
</style>
  <div class="container">
    <div class="row">
      <div class="col-md-8 brd">
        <div class="row scroll-hold">
          <div class="col content" style="width:50%">
            test test test <br>
            test test test <br>
            test test test <br>
          </div>
          <div class="col content back-clr">
            this is second div
          </div>
        </div>
      </div>
    </div>
  </div>

布莱德先生{
边框:1px纯灰;
}
.内容{
浮动:左;
宽度:50%;
}
.back clr{
背景色:红色;
}
.滚动保持{
溢出:自动;
最大高度:200px;
}
测试
测试
测试
这是第二组

如果您查看Inspector(Firefox中的菜单(3条)>WebDeveloper>Inspector),您可以看到完整的div变为红色。如果你想让整个高度变成红色,你必须把div的高度调大

在这里复制答案- 给予


Jfiddle这里-

只需添加高度:200px;像这样

.back-clr{
    background-color: red;
   height: 200px;
 }

你应该表现得很好。我希望这会有所帮助:)

您能否更新问题,以便更清楚地了解您希望获得的预期结果?具体来说,您希望为整个容器、包含类内容的div或仅第二个div设置背景颜色?第二个div应完全填充。现在部分填充。您能接受或拒绝回答吗?
.back-clr{
    background-color: red;
   height: 200px;
 }