首页 > 解决方案 > 我应该如何将此文本放置在我的图像上?

问题描述

就是我想要重建的。

到目前为止,这就是我对 HTML 的了解:

.carousel-cell {
  position: relative;
}

.board-text {
  position: absolute;
  top: 50%;
}
<div class="carousel-cell">
  <img src="img/board1.png" alt="">
  <div class="board-text">
    <h4>Funboards</h4>
    <h2>Chilli Rare Bird</h2>
    <h3>$890</h3>
    <p>Buy</p>
  </div>
</div>

标签: htmlcss

解决方案


无法在 an 上放置文本,<img>但您可以创建一个框,然后将图像作为background-image. 然后你可以在框中写下你想要的文字。HTML 示例:<div id="imageBox">Your text</div> CSS:#imageBox{background-image: url(img/board1.jpg)} 希望这会有所帮助;)


推荐阅读