我正在尝试通过Appearance>Customize中的附加WordPress部件来修改我的CSS主题。
我希望entry-content类中的所有h1
标记都是这样的:
所以我使用了下面的代码:
.entry-content h1 {
background-color: #cfbc00;
display: inline;
background-color:#000000;
}
我希望整个块是彩色的#cfbc00
和文本本身的背景是黑色的。但是浏览器不会同时对我的标签应用这些属性,它只应用其中一个属性。我该怎么办?
发布于 2018-07-21 20:31:13
如果您不能访问HTML代码,那么这里有一个CSS解决方法:
.entry-content
{
position: relative;
}
.entry-content h1::before
{
content: "";
display: block;
position: absolute;
width: 100%;
background-color: #cfbc00;
height: 40px;
z-index: -1;
}
.entry-content h1 {
display: inline;
background-color: #000000ad; /* Sets transparency according to sample image */
top: 0;
/* Line height to maintain the height of the :before element */
line-height: 40px;
color: #fff;
font-size: 35px;
padding: 5px;
}
<div class="entry-content">
<h1>Test title</h1>
</div>
https://stackoverflow.com/questions/51455996
复制相似问题