繁体   English   中英

如何覆盖引导程序的容器的填充

[英]how to override bootstrap's container's padding

我有一个带有容器引导程序类的 div。 所以容器类在左侧和右侧提供了 15px 的填充。 我想为我的容器的所有子元素保留填充,但我希望一个 div 粘在容器的两侧而不完全删除引导程序填充。 那可能吗 ?

<div class="container">
  <div>first div</div>
  <div>second div div</div>
  <div>div that has to stick on the sides</div>
  <div>another random div</div>
</div>

Bootstrap 中的容器类为装订线设置了 15px 的左右内边距。 您可以通过使用负边距来抵消您通过以下方式指定的 div:

div.container > div:nth-child(3){
  margin: 0 -15px;
}

尝试这个

 .container{ background-color: blue; } div{ background-color: wheat; } #fullWidth{ margin: 0 -15px; }
 <div class="container"> <div id='fullWidth'>first div</div> <div>second div div</div> <div>div that has to stick on the sides</div> <div>another random div</div> </div>

暂无
暂无

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

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