我正在使用此代码
#main-header::after {
content: "";
background-image: url('xxxx');
background-size:cover;
opacity: 1.0;
top: -45%;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
我希望它在除主页之外的所有页面都有效,因为我有一个全宽滑块,我该怎么办?我在Wordpress上使用这个自定义CSS。谢谢!
答案 0 :(得分:3)
您可以使用类似How to exclude particular class name in CSS selector?
的正文类来使用类排除选择器所以你的代码将成为:
body:not(.home) #main-header::after {
content: "";
background-image: url('xxxx');
background-size:cover;
opacity: 1.0;
top: -45%;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
答案 1 :(得分:1)
<?php if(!is_home()){ ?>
<style type="text/css">
#main-header::after {
content: "";
background-image: url('xxxx');
background-size:cover;
opacity: 1.0;
top: -45%;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
</style>
<?php } ?>