gpt4 book ai didi

html - 如何防止按钮与 Bootstrap 中的 .btn-group 类相互合并?

转载 作者:太空宇宙 更新时间:2023-11-04 11:31:56 26 4
gpt4 key购买 nike

在 bootstrap 中使用 .btn-group 类时,如何防止一列按钮折叠成另一列?在此示例中,当减小页面宽度时,右侧的列会折叠到中间的列中。我应该使用另一个类(class)来防止这种情况发生吗?下面是 JsFiddle 实例。

桌面屏幕尺寸: enter image description here

较小的屏幕尺寸: enter image description here

HTML:

<div class="industry_center_button">
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right ">AdTech</a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button">B2B</a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button"><span class="industry_button_multiline">Consumer Electronics</span></a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right "><span class="industry_button_multiline">Digital Media</span></a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button">eCommerce</a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button"><span class="industry_button">Employent</span></a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right ">Ed Tech</a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button"><span class="industry_button_overflow">Entertainment</span></a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button">Fashion</a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right ">Fin Tech</a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button">Fitness</a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button">Gaming</a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right "><span class="industry_button_multiline">Internet of Things</span></a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button">Media</a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button"><span class="industry_button_multiline">Non-profit</span></a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right ">Other</a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button"><span class="industry_button_multiline">Public Relations</span></a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button">Publishing</a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right "><span class="industry_button_multiline">Real Estate</span></a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button">Security</a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button">Software</a>
</div>
</div>
</div>
<div class="row">
<div class="btn-group">
<div class="col-xs-4 industry_button_padding industry_button_left">
<a href="#" class="btn btn-lg btn-default industry_button pull-right "><span class="industry_button_multiline">Travel &amp; Hospitality</span></a>
</div>
<div class="col-xs-4 industry_button_padding">
<a href="#" class="btn btn-lg btn-default industry_button">Wearables</a>
</div>
<div class="col-xs-4 industry_button_padding industry_button_right ">
<a href="#" class="btn btn-lg btn-default industry_button" style="visibility: hidden;"></a>
</div>
</div>
</div>
</div>

CSS:

.industry_button {
font-size: 10pt;
width: 98px;
height: 41px;
text-align: center;
background-color: #F2F2F2;
white-space: normal;
vertical-align: middle;
}
.industry_button_multiline {
position: relative;
bottom: 7px;
}
.industry_button_overflow {
position: relative;
right: 12px;
}
.industry_button_padding {
padding-top: 1px;
padding-bottom: 1px;
}
.industry_button_left {
position: relative;
left: 25px;
}
.industry_button_right {
position: relative;
right: 25px;
}
.industry_center_button {
margin: auto;
width: 30%;
display: block;
}
.btn-group {
padding-top: 5px;
padding-bottom: 5px;
}

这是 fiddle以实例为例。

最佳答案

是您的 .industry_button_right.industry_center_button 类导致它们重叠。您为 .industry_center_button 设置了 width: 30%;,它限制了较小屏幕上按钮的列宽/空间以及 right: 25px;.industry_button_right 设置,将第三个按钮推到它自然想要放置的位置的右​​侧。

关于html - 如何防止按钮与 Bootstrap 中的 .btn-group 类相互合并?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31973496/

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