【发布时间】:2018-06-18 18:02:21
【问题描述】:
我正在尝试设计这样的标题,其中标语和背景图片附加在所述图片中。我想使用 flex 让它工作,但它不工作。给出宽度会破坏响应能力。我创建了一个 jsbin 来展示演示,这里是
http://jsbin.com/muguwavosa/edit?html,css,output
源代码
.header {
display: flex;
flex-direction: column;
background-image: url('https://www.rj-investments.co.uk/wp-content/uploads/2018/02/Home-Featured.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
padding: 100px 0;
}
.slogan-wrapper {
background: #fff;
padding: 80px 0 0 40px;
margin-top: 70px;
}
.slogan-text > h1 {
font-size: 3.375rem;
font-weight: 900;
letter-spacing: 5px;
color: #373f48;
}
.slogan-text {
padding: 100px 70px 100px 0;
position: relative;
background: #fff;
z-index: 1;
}
<div class="header">
<div class="slogan-wrapper grid">
<div class="slogan">
<div class="slogan-text">
<h1>Hustle, Loyalty, Respect</h1>
</div>
</div>
</div>
这正是我想要的,它是一个全宽标题
【问题讨论】:
标签: html css responsive-design flexbox