将文本置于两种不同的纯色背景之上

Place a text above two different solid background colors

有谁知道如何在两种不同的纯色背景上放置文本?同时,它在最小化屏幕时保持响应。我已经看到很多人这样做了,但是,我仍在研究编码这种风格的标准方法。下面我添加了我想要做的样式的图像。感谢您的时间。

这可能对您有所帮助。 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>

我仍然认为 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);
}
<div id="div">COLOR STOP AT 50%</div>

<div id="div2">COLOR STOP AT 25%</div>

<div id="div3">COLOR STOP AT 75%</div>

这里有更多关于使用它们的信息:https://css-tricks.com/css3-gradients/