0
因此我创建了一个带有标题的图像库,并且我像以前一样困惑,我从来没有这样做过,但现在当我设置p元素的背景颜色,它也设置元素背后的背景。到目前为止,我已经尝试了几件事情,比如将图像的背景颜色设置为none和其他东西,但没有任何工作,任何帮助将不胜感激!这里是我的代码片段,我会很乐意更新所需的更多信息。如何设置ap元素的背景颜色也为上面的图像设置背景颜色
HTML
<div id="wrapper">
<ul id="products">
<li><a href="ambco.html"><img src="img/650a.jpg" alt=""><p>Hello I am Jacob
and I'm confused as hell and this doesn't make sense...</p></a></li>
<li><p>Hello I am Jacob and I'm confused as hell and this doesn't
make sense...</p></li>
<li><p>Hello I am Jacob and I'm confused as hell and this doesn't
make sense...</p></li>
</ul>
</div>
CSS
#products {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#products li {
width: 95%;
margin: 2.5%;
float: left;
}
#products img {
margin-bottom: 15px;
}
#products p {
background-color: black;
color: brown;
}
#products a {
text-decoration: none;
}
你能用jsfiddle重现吗?我没有和你的代码一样的输出:https://jsfiddle.net/hsmb1pqz/ – Michael
你发布了我自己的链接,你需要点击编辑按钮,左上角 – Michael
是啊我很笨:/ https: //jsfiddle.net/boo89100/xx0eq2t6/ – Boo89100