答案 0 :(得分:0)
这可能会对你有所帮助。 https://jsfiddle.net/67uxvnq7/1/
.div1 {
position: relative;
width: 100%;
height:50vh;
background: pink;
}
.div2 {
position: relative;
width: 100%;
height: 50vh;
background: red;
}
span {
font-size: 50px;
font-weight:bold;
color: #000;
position: absolute;
bottom: -25px;
z-index:1;
width:100%;
text-align:center;
}

<div class="div1">
<span>HELLO WORLD</span>
</div>
<div class="div2">
</div>
&#13;
答案 1 :(得分:0)
我仍然认为CSS渐变是要走的路。如果需要,您可以设置颜色停止位置。它也不依赖于设定高度。
div {
background-image: linear-gradient(to bottom, #ee615f, #ee615f 50%, #9f3e3e 50%, #9f3e3e);
font-family: sans-serif;
font-size: 40px;
line-height: 1;
padding: 25px 0;
margin-bottom: 25px;
text-align: center;
}
#div2 {
background-image: linear-gradient(to bottom, #ee615f, #ee615f 25%, #9f3e3e 25%, #9f3e3e);
}
#div3 {
background-image: linear-gradient(to bottom, #ee615f, #ee615f 75%, #9f3e3e 75%, #9f3e3e);
}
&#13;
<div id="div">COLOR STOP AT 50%</div>
<div id="div2">COLOR STOP AT 25%</div>
<div id="div3">COLOR STOP AT 75%</div>
&#13;
以下是有关使用它们的更多信息:https://css-tricks.com/css3-gradients/