【发布时间】:2019-09-15 13:56:09
【问题描述】:
我有一个bootstrap 按钮:
<div class="float-right" >
<label>show as </label>
<input class="btn btn-outline-primary rounded active" type="button" value="percentage" onclick="toggle(this)" />
</div>
我使用以下方式切换文本:
<script type="text/javascript">
function toggle(button) {
if(button.value=="percentage") {
button.value="units";
} else {
button.value="percentage";
}
}
</script>
当文本从较长的单词 percentage 更改为较短的单词 units 时,如何获得按钮不调整大小。即,我希望按钮保持与具有文本 percentage 时相同的大小。
请注意,我宁愿不使用 style="min-width: 120px;" 对大小进行硬编码。
【问题讨论】:
-
相关:stackoverflow.com/a/55328972/8620333(如果您能够使用
buttoninsitead ofinput)
标签: html css twitter-bootstrap button resize