【发布时间】:2018-07-07 07:19:26
【问题描述】:
我正在尝试使 div 具有特定大小的背景颜色,但是每当我将绝对位置放在 div 内部的内容上时,它都会删除背景颜色。
这是我正在尝试做的图片:
[![在此处输入图片描述][1]][1]
* {
font-family: 'Poppins', sans-serif;
}
.background {
position: relative;
background: #DFEDFF;
height: 100%;
width: 100%;
}
.hero-text {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.title {
font-size: 8.4375rem;
font-weight: 800;
line-height: 130px;
margin: 0;
}
.description {
margin: 0;
font-size: 2.75rem;
font-weight: 300;
}
<div class="background">
<div class="hero">
<div class="hero-text">
<h1 class="title">Hello,<br>I'm Ian</h1>
<p class="description">Website coming soon.</p>
</div>
<img class="callum" src="images/callum.png" alt="">
</div>
</div>
【问题讨论】:
-
你想达到哪个结果。你的设计应该看起来像图像还是小提琴结果??
-
@FridayAmeh 请提供图片
-
试一试——这有帮助吗? jsfiddle.net/3pL5srvq/2
标签: css