带有CSS的文本溢出图像效果?

伊桑2406

在开始之前,我不是指text-overflowCSS 中的那些。我实际上指的是其中之一:

溢出图像的文本的屏幕截图

我在这里想要实现的是文本有目的地与图像相交或溢出。这样,你就得到了你从图片中看到的文本溢出效果。知道这是如何使用 CSS 实现的吗?

德拉卢亚

您可以将文本放在覆盖容器中,这样,您可以根据需要添加更多项目。在 codepen 上演示

.container {
  position: relative;
  width: 100%;
  min-height: 600px;
  border: 1px solid black;
  display: flex;
  justify-content: right;
}

.container img {
  width: 50%;
  height: auto;
  object-fit: cover;
}

.container h4 {
  font-size: 3rem;
  max-width: 60%;
}

.overlay {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  display: flex;
  align-items: center;
}
<div class="container">
  <img src="https://images.pexels.com/photos/2857477/pexels-photo-2857477.jpeg?cs=srgb&dl=pexels-deepu-b-iyer-2857477.jpg&fm=jpg" />
  <div class="overlay">
    <h4>Apparently, we had reached a great height in the athmosphere
    </h4>
  </div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章