gpt4 book ai didi

html - 在我的案例中如何正确设置元素的边距

转载 作者:行者123 更新时间:2023-11-28 08:26:59 24 4
gpt4 key购买 nike

我正在尝试使用 bootstrap 在 div 中添加一堆元素

我有类似的东西

<div class="row">
<div class="col-xs-8">
//contents
</div>

<div id="forms" class="col-xs-4">
<div class="title">My first app</div> //no stretch
<div class="form-group"> //stretch to the edge
//contents
</div>
<div class="form-group"> //stretch to the edge
//contents
</div>
</div>
</div>

我的问题是表单组有默认的 margin-left:-15pxmargin-right:-15px css。所以表单看起来一直延伸到 forms div 的边缘。

我可以手动设置 margin:0 来覆盖这些表单的 css,但我不确定这是否是 bootstrap 中的最佳实践。谁能帮我解决这个问题?谢谢!

最佳答案

使用容器类

Bootstrap :

  1. 容器

当你跳过一个 lvl 时,你很可能会卡在边缘 http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

<div class="container">
<div class="row">
<div class="col-xs-8">
//contents
</div>

<div id="forms" class="col-xs-4">
<div class="title">My first app</div> //no stretch
<div class="form-group"> //stretch to the edge
//contents
</div>
<div class="form-group"> //stretch to the edge
//contents
</div>
</div>
</div>
</div>

关于html - 在我的案例中如何正确设置元素的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28488512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com