大佬教程收集整理的这篇文章主要介绍了如何使用引导程序实现 100% 宽度,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚开始使用引导程序,但无法将宽度设置为 100%。我尝试在我的容器 CSS 上分配 wIDth:100%;
但这没有用。我遇到的唯一解决方案是在我的 div 类中设置 container-fluID no-padding
(并且它有效)但我读到设置无填充很糟糕,因为它违背了引导程序 15px 填充预设。在引导程序中将宽度设置为 100% 的正确方法是什么?提前致谢。
HTML
.con-1{
border: 1px solID green;
height: 100%;
position: absolute;
left: 0%;
}
.row-1{
border: 3px solID red;
BACkground-color: white;
height: 75%;
}
.row-2{
border: 3px solID red;
BACkground-color: white;
height: 25%;
}
.col-1{
border: 3px dotted blue;
wIDth: 95%;
}
.col-2{
border: 3px dotted blue;
wIDth: 5%;
}
.col-3{
border: 3px dotted blue;
wIDth: 31.6%;
}
.col-4{
border: 3px dotted blue;
wIDth: 31.6%;
}
.col-5{
border: 3px dotted blue;
wIDth: 31.6%;
}
.col-6{
border: 3px dotted blue;
wIDth: 5%;
}
<div class="container con-1">
<div class ="row row-1">
<div class="col-lg-11 col-md-11 col-1">
Row 1 Col 1
</div>
<div class="col-lg-1 col-md-1 col-2">
Row 1 Col 2
</div>
</div>
<div class ="row row-2">
<div class="col col-3">
Row 2 Col 1
</div>
<div class="col col-4">
Row 2 Col 2
</div>
<div class="col col-5">
Row 2 Col 3
</div>
<div class="col col-6">
Row 2 Col 4
</div>
</div>
</div>
正如@pete 建议的那样,使用 container-fluid
代替容器将解决此问题并将容器宽度设置为 100%。
<div class="container-fluid con-1">
<div class ="row row-1">
<div class="col-lg-11 col-md-11 col-1">
Row 1 Col 1
</div>
<div class="col-lg-1 col-md-1 col-2">
Row 1 Col 2
</div>
</div>
<div class ="row row-2">
<div class="col col-3">
Row 2 Col 1
</div>
<div class="col col-4">
Row 2 Col 2
</div>
<div class="col col-5">
Row 2 Col 3
</div>
<div class="col col-6">
Row 2 Col 4
</div>
</div>
</div>
,
有几种方法可以实现这一点。
如果您想拥有一个真正的 100% 宽度元素,只需在您的 div 上放置一个 w-100
类,而无需 container
。
在您的情况下,当您使用 container
时,将其替换为流体 container-fluid
,并添加一个 p-0
类。
请参考 Bootstrap 文档: Spacing、Containers
以上是大佬教程为你收集整理的如何使用引导程序实现 100% 宽度全部内容,希望文章能够帮你解决如何使用引导程序实现 100% 宽度所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。