【发布时间】:2017-03-03 19:00:08
【问题描述】:
我很抱歉发布另一个垂直对齐问题,但由于我是一个完全的初学者,我不知道还能做什么。
我有一个全屏背景图像,我想垂直对齐 h1、p 和按钮部分,所以无论屏幕高度是多少,文本块都应该始终居中。我试图通过在该部分添加 margin-top 来实现这一点,但这并不完美。我正在使用 Bootstrap。
这是我的 HTML:
<section id="home">
<div class="container">
<div class="row">
<div class="col-md-6">
<h1>dolm it</h1>
<p>Dolm IT is modern design & development agency from Estonia with main focus on complex web systems. We have a really kickass team whose main focus is UI/UX, PHP, Java, AngularJS, HTML & CSS.</p>
<button type="button" class="btn btn-default white">more</button>
</div>
</div>
</div>
<!--end container-->
</section>
<!--end home-->
这是我创建的 CSS:
#home {
background: -webkit-linear-gradient( rgba(14, 124, 132, 0.8), rgba(14, 124, 132, 0.8)), url(../img/landing_bg.jpg) no-repeat 0 30% fixed;
background: linear-gradient( rgba(14, 124, 132, 0.8), rgba(14, 124, 132, 0.8)), url(../img/landing_bg.jpg) no-repeat 0 30% fixed;
background-size: cover;
width: 100%;
height: 100vh;
}
#home h1 {
color: #ffffff;
font-family: 'Akrobat-ExtraBold';
font-size: 4.9rem;
text-transform: uppercase;
letter-spacing: 2px;
margin-bottom: 32px;
}
#home p {
color: #ffffff;
font-family: 'Akrobat-Bold';
font-size: 1.5rem;
}
#home .col-md-6 {
margin-top: 200px;
padding: 130px 0 130px 0;
}
你可以看到测试页面here。感谢您的帮助。
【问题讨论】:
-
感谢您的回复和链接。我设法实现了我想要的。由于我是新手,我自己找不到这个解决方案。
标签: html css twitter-bootstrap alignment vertical-alignment