【发布时间】:2022-01-24 02:55:25
【问题描述】:
我正在尝试将按钮移动到文本下方(当前显示“测试?”),但换行符什么也没做。我已经用谷歌搜索了所有我能想到的东西,但找不到任何关于此的信息,因此不胜感激!
按钮的 HTML 和 CSS(如果相关):
.custom-button,
.custom-button:visited {
display: flex;
justify-content: center;
align-items: center;
padding: 5px 10px;
border: 2px solid #FFF;
}
.custom-button:hover {
background: #000;
color: #FFF;
}
<h1>
Test? <br>
<a class="custom-button" href="#scroll">Click Me</a>
</h1>
编辑:这也是标题的代码,似乎 display: flex 部分导致了问题,但是如果没有它,我如何垂直居中文本?这对我来说是全新的,所以谢谢你的帮助!
h1 {
font-size: 62px;
font-family: "Sofia", sans-serif;
color: cyan;
text-align: center;
vertical-align: middle;
background-color: grey;
background-repeat: no-repeat;
background-position: center;
margin: -10px;
height: 110%;
display: flex;
justify-content: center;
align-items: center;
}
【问题讨论】:
-
看起来
h1元素有display: flex或其他导致此问题的设置。您应该发布完整的相关代码(HTML 和 CSS,以及父元素) -
你真的需要
display:flex上的h1元素吗?