个性化阅读
专注于IT技术分析

如何同时向标签添加多个CSS属性?

点击下载

我正在尝试通过外观>自定义中的其他CSS部分修改我的WordPress主题。

我希望条目内容类中的所有h1标签都像这样:

这个图片

所以我使用了这段代码:

.entry-content h1 {
  background-color: #cfbc00;

    display: inline;
    background-color:#000000;
}

我希望将整个块着色为#cfbc00并将文本本身的背景设置为黑色。但是浏览器不会将这些属性同时应用于我的标签, 并且仅应用了其中一个属性。我该怎么办?


#1


如果你无权访问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>
赞(0)
未经允许不得转载:srcmini » 如何同时向标签添加多个CSS属性?

评论 抢沙发

评论前必须登录!