【发布时间】:2019-02-26 17:56:53
【问题描述】:
我正在尝试使用标题和下方的按钮来设置部分的样式,并希望无论浏览器大小如何,按钮都能完美地保持一致(除非在移动设备上它们会堆叠)。 由于一个标题中的文本比另一个标题多,当我更改屏幕大小时,一些标题从一行变为需要使用两行,迫使按钮在页面上降低,而另一个按钮保持不变。
我有弹性盒子里的项目,但有没有办法强迫它们保持一致?
-
编辑:
我最近尝试的是删除按钮并将它们放在下面自己的部分中。
我也尝试了这个解决方案here,通过定位新的部分 id,没有成功。
这是我有问题的原始代码。
/* Section: Clients */
#clients .items {
display: flex;
}
#clients .items img {
display: block;
position: center;
margin: auto;
width: 50%;
}
#clients .cr {
position: relative;
min-width: 29%;
max-width: 30%;
height: auto;
text-align: center;
padding-top: 0px;
padding-left: 15px;
padding-right: 15px;
margin-left: 30px;
}
#clients .cr-last {
position: relative;
min-width: 29%;
max-width: 30%;
height: auto;
text-align: center;
padding-top: 0px;
padding-left: 15px;
padding-right: 15px;
margin-left: 30px;
}
#clients .client-r {
margin-right: 50px;
}
#clients .cr-btn {
background-color: #4C9FCF;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
<!-- Section: Client Resources -->
<section id="clients" class="py-1">
<div class="container">
<h2 class="m-heading text-center">
<span id="client-r" class="text-primary">Client</span> Resources
</h2>
<div class="items py-1">
<div class="cr">
<h2>
TD Ameritrade Access
<p></p>
</h2>
<button class="cr-btn">LOGIN</button>
</div>
<div class="cr">
<h2>
American Equity Access
<p></p>
<button class="cr-btn">LOGIN</button>
</h2>
</div>
<div class="cr-last">
<h2>
American Equity Access
<p></p>
<button class="cr-btn">LOGIN</button>
</h2>
</div>
</div>
</div>
</section>
【问题讨论】:
-
欢迎来到 Stack Overflow!发布的问题似乎根本不包括解决问题的任何尝试。 StackOverflow 希望您首先尝试解决自己的问题,因为您的尝试有助于我们更好地了解您想要什么。请编辑问题以显示您尝试过的内容,以说明您在Minimal, Complete, and Verifiable example 中遇到的特定问题。欲了解更多信息,请参阅How to Ask 并拨打tour。