去掉 wordpress hestia 主题轮播图区域的背景色

更新日期: 2018-05-04 阅读次数: 6940 分类: CSS

hestia 主题顶部的 .header-filter 部分是一个背景图,但是被加了一层阴暗的遮罩色。经常有同事反馈说太阴暗了这个色调,不适合作为官网的主色调。

来看看 hestia 的 style.css 里的代码

.header-filter {
    background-image: url(https://www.sunzhongwei.com/wp-content/uploads/2018/05/meitu_1.jpg);
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: -1;
    background-position: center center;
    background-size: cover;
}

.carousel .header-filter:before, .carousel .header-filter:after {
    z-index: -1;
}

.header-filter::before {
    background-color: rgba(0, 0, 0, 0.5);
}

.header-filter:before, .header-filter:after {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    content: "";
}

处理办法就是在 wordpress 后台的额外 css 中添加几行

.header-filter::before {
    background:none !important;
}

记录这个的原因是,学习一下在背景图前面增加遮罩色的实现方法。

遮罩的其他实现方式

hestia-robin 则是用 after 实现的,而不是 before

.section-image:after {
    display: block;
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
}

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式