html - <p> 标签总是在 <div> 的背景下

标签 html css background-image

所以基本上我希望我的 p 标签总是显示在我的背景图片下。如果我将窗口变小,p 标签不应与 background-image 重叠。

我知道在源代码中将它作为一个 img 添加到一个单独的 div 中会有很大帮助,但对此的回答会很好。

HTML:

 <div class="champ-link img-background">
    <a>
      <p>browse the selection</p>
    </a>
 </div>

CSS:

.img-background {
     background-image: url(test.jpg);
     background-repeat: no-repeat;
     background-size: 50px 63px; 
}

最佳答案

.img-background {
   background-image: url(test.jpg);
   background-repeat: no-repeat;
   background-size: 50px 63px; 
   padding-top: 63px;
}

p {
   margin-top: 63px;
}

关于html - <p> 标签总是在 <div> 的背景下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40265397/

相关文章:

css - 使用 CSS 添加控件到 HTML5 背景视频

css - 背景图片在 iPad 1 上不显示,但在 iPad 2 上显示

css - Chrome 72 是否破坏了 css 背景 svgs 的 'data:image/svg+xml;utf8'?

CSS3 : How do I make a linear gradient on top of an image suitable for cross browser compatibility?

html - 悬停在文本上时如何为 "scale and rotate image"?

html - 如何使用 Flutter Mailer Package 发送复杂的邮件

javascript - 添加更改图像的链接

html - 在 ul 标签中垂直对齐按钮

html - 悬停图像时出现奇怪的星号?

jquery - 可折叠的 Bootstrap 表格行