我试图垂直和水平对齐文字和按钮,但却无法做到...... 我最终想要的是对齐是否响应。 我的代码: HTML:
<div id="stage">
<div id="stage-caption">
<h1 class="display-3">Gallery Nellija</h1>
<p>Some description</p>
<a href="" class="btn btn-lg btn-success">Sign up now</a>
</div>
</div>
CSS:
#stage {
background: url('img/stage.jpg') center center no-repeat;
background-size: cover;
color: white;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#stage-caption {
font-size: 1.4rem;
font-weight: 200;
max-width: 60rem;
margin: 0 auto;
}
#stage-caption h1 {
color: white;
font-weight: bold;
text-transform: uppercase;
}
现在它看起来像是:
提前致谢!
答案 0 :(得分:1)
将text-align:center
添加到#stage