html - 我可以让按钮中的文本使用换行符吗
问题描述
如果用户屏幕小于文本大小,如何使按钮文本以多行显示。
就目前而言,如果用户的屏幕宽度较小,则屏幕上会丢失一些文本。
.column {
box-sizing: inherit;
display: inline-block;
margin-bottom: 0em;
margin-top: 0em;
vertical-align: middle;
width: 100%;
}
.margin-top {
margin-top: 1.6rem;
}
.centered {
box-sizing: inherit;
text-align: center;
}
.btn {
-webkit-tap-highlight-color: transparent;
background-color: #00bd9a;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px, rgba(0, 0, 0, 0.2) 0px 3px 1px -2px;
box-sizing: inherit;
color: white;
cursor: pointer;
display: inline-block;
height: 42px;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
text-transform: uppercase;
vertical-align: middle;
width: 80%;
}
<div class="column">
<div class="margin-top centered">
<a class="btn" href="#" style="">
Text Here
</a>
</div>
</div>
解决方案
添加height:auto
到btn
课堂
.column {
box-sizing: inherit;
display: inline-block;
margin-bottom: 0em;
margin-top: 0em;
vertical-align: middle;
width: 100%;
}
.margin-top {
margin-top: 1.6rem;
}
.centered {
box-sizing: inherit;
text-align: center;
}
.btn {
-webkit-tap-highlight-color: transparent;
background-color: #00bd9a;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px, rgba(0, 0, 0, 0.2) 0px 3px 1px -2px;
box-sizing: inherit;
color: white;
cursor: pointer;
display: inline-block;
height: auto;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
text-transform: uppercase;
vertical-align: middle;
width: 80%;
}
<div class="column">
<div class="margin-top centered">
<a class="btn" href="#" style="">
Text Here
</a>
</div>
</div>
推荐阅读
- angular - 仅获取特定页面的列表数据
- java - 如何根据用户在 EditText 中键入的内容不断更新字符串?
- php - (PHP) 'If' 语句仅在一侧回显,它会更改为 'else' 并根据添加到购物车的产品更改回 'if'
- python - 如何从文件中读取带引号的字符串并在不带引号的情况下写入?
- python - 不可能将货币价值绘制成图
- c# - VB.Net Winform Radiobutton 的所有属性都设置为 ReadOnly = True
- python - 完成子图的步骤
- python - 比较不同年份的相同月份值
- python - 使用存储在类中的 JSON 数据?
- javascript - 包含内容和来源的脚本如何工作?