当一个按钮上的文本换行成两行时,按钮会跳出与其他按钮的行,在这里阅读类似的问题buttons with 2 lines of text are larger than buttons with 1 line of text, but i need them all to be the same size as the 1 line(与按钮大小有关)时,它说要确保设置宽度和高度。我已经设置了这些,但与一行版本相比,两行按钮仍然不一致。
我怎样才能强制它们都是相同的集合大小,并始终保持彼此内联?
.qcontain {
width: 400px;
display: inline-block;
}
.qnumber {
display: inline-block;
}
.qtext {
display: inline-block;
color: #666666;
font-family: Arial;
font-size: 18px;
font-weight: bold;
}
.abutton {
box-shadow: inset 0px 1px 0px 0px #ffffff;
background: linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%);
background-color: rgba(0, 0, 0, 0);
background-color: #f9f9f9;
border-radius: 12px;
border: 4px solid #dcdcdc;
display: inline-block;
cursor: pointer;
color: #666666;
font-family: Arial;
font-size: 15px;
font-weight: bold;
padding: 10px 10px;
text-decoration: none;
text-shadow: 0px 1px 0px #ffffff;
width: 195px;
height: 100px;
margin-left: 3px;
margin-top: 3px;
white-space: normal;
}
.abutton:hover {
background: linear-gradient(to bottom, #e9e9e9 5%, #f9f9f9 100%);
background-color: #e9e9e9;
}
.abutton:active {
position: relative;
top: 1px;
}
<div class="qcontain">
<h1 class="qnumber">Q1:</h1><br>
<div class="qtext">Should you eat yellow snow?</div><hr>
<button class="abutton">Hell Yeah</button><button class="abutton">Never</button><br>
<button class="abutton">Only on Tuesdays</button><button class="abutton">Only as part of balanced diet</button>
</div>
2条答案
按热度按时间avkwfej41#
我现在已经让他们排队与css网格,但不能帮助认为这是矫枉过正,我只是错过了一些简单的在我的第一次尝试。
iq3niunx2#
更简单的解决方案是将
vertical-align: top;
添加到.abutton
样式中。