【发布时间】:2021-07-30 06:59:04
【问题描述】:
我在一个 div 中有 3 个元素,我希望它们在一个块中(垂直)并水平和垂直对齐。这是它现在的样子:
这是我的代码:
<div className="parent">
<p className="heading">TITLE</p>
<p className="description"><strong>DISCLAIMER</strong>: The site contains offensive, vulgar langauge which may not be<br/>suitable for many, so enter with caution and do not reveal any personal details</p>
<Link to="/school"><button className="enterButton">enter the website</button></Link>
</div>
----------------------
stylesheet.css
----------------------
.parent {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.heading {
font-size: 76px;
text-align: center;
}
.description {
font-size: 18px;
opacity: .7;
text-align: center;
line-height: 26px;
}
.enterButton {
width: 360px;
height: 100px;
background-color: #E1E8ED;
color: #15202B;
font-size: 32px;
font-weight: bolder;
text-align: center;
border: none
}
我希望它们对齐并在彼此下方,例如:
TITLE
Disclaimer
Enter the website
【问题讨论】:
-
.parent需要,flex-direction: column; -
@dalelandry 我无法形容现在的幸福,伙计,在这个微不足道的问题上度过了两个不眠之夜!非常感谢!!
标签: html css reactjs alignment vertical-alignment