带有文字的背景图片

时间:2018-09-25 16:52:39

标签: html css css3

我的目标是得到这样的结果: enter image description here

现在,我希望文本位于背景图像中。 我认为我的问题可能出在HTML中吗?

这里是概述 enter image description here

.background_grey {
  height: 70px;
  width: 100%;
  margin-top: 0px;
  position: relative;
}

.page_title {
  font-size: 14px;
}
<img class="background_grey" src="images/subtle_grunge.png" />
<div class="page_title">Register <span class="hometxtcolor">an Account</span></div>

谢谢您的帮助!

2 个答案:

答案 0 :(得分:1)

您必须通过CSS使用背景图片,而不是通过img元素:

.page_title {
  background-image: url(images/subtle_grunge.png);
}
<div class="page_title">
  Register
  <span class="hometxtcolor">
          an Account
        </span>
</div>

答案 1 :(得分:-2)

https://www.w3schools.com/howto/howto_css_image_text.asp

在此处查找完整的解决方案...

相关问题