gpt4 book ai didi

css - 如何在不使用自动调整大小的情况下制作灵活的按钮

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

我是 CSS 的新手,我有按钮,顶部有文本和值,值是可变的,有时大有时小,我希望我的按钮大小相同但可以根据值的大小灵活调整,我也提供了一个演示来更好地阐明我的问题:

.btnsForCrew-Common {
border-radius: 10px;
font-size: xx-small;
width: 15%;
}

.CrewPrsntButtonsIdle {
color: black;
background: linear-gradient(to bottom, lightgreen 15%, white 10%);
}

.FontsForCrewPresents {
font-size: 40px
}
<button type="button" id="btnIdle" class="btnsForCrew-Common CrewPrsntButtonsIdle"> 
<span style="color:black;font-weight:bold;">ERROR</span>
<br><br>
<span class="FontsForCrewPresents"> 254</span>
</button>

<button type="button" id="btnIdle1" class="btnsForCrew-Common CrewPrsntButtonsIdle">
<span style="color:black;font-weight:bold;">IDLE</span>
<br><br>
<span class="FontsForCrewPresents"> 100</span>
</button>

<button type="button" id="btnIdle2" class="btnsForCrew-Common CrewPrsntButtonsIdle">
<span style="color:black;font-weight:bold;">WAITING To RUN</span>
<br><br>
<span class="FontsForCrewPresents"> 600000</span>
</button>

我不想自动调整大小的原因是;它使尺寸不同,我不想要那样。这是演示:

DEMO

最佳答案

您可以通过将它们包装在一个内联 block 元素中并使它们的宽度为 100% 来使它们的大小相同 - 然后它们将与最大的一样长:

.wrapper {
display:inline-block;
}
.wrapper > button {
width:100%;
}

.btnsForCrew-Common {
border-radius: 10px;
font-size: xx-small;
}

.CrewPrsntButtonsIdle {
color: black;
background: linear-gradient(to bottom, lightgreen 15%, white 10%);
}

.FontsForCrewPresents {
font-size: 40px;
line-height:40px;
}
<div class="wrapper">
<button type="button" id="btnIdle" class="btnsForCrew-Common CrewPrsntButtonsIdle">
<span style="color:black;font-weight:bold;">ERROR</span>
<br><br>
<span class="FontsForCrewPresents"> 254</span>
</button>

<button type="button" id="btnIdle1" class="btnsForCrew-Common CrewPrsntButtonsIdle">
<span style="color:black;font-weight:bold;">IDLE</span>
<br><br>
<span class="FontsForCrewPresents"> 100</span>
</button>

<button type="button" id="btnIdle2" class="btnsForCrew-Common CrewPrsntButtonsIdle">
<span style="color:black;font-weight:bold;">WAITING To RUN</span>
<br><br>
<span class="FontsForCrewPresents"> 600000</span>
</button>
</div>

关于css - 如何在不使用自动调整大小的情况下制作灵活的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50504350/

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