如何在没有页面或帖子 ID 的情况下使用 :not()? [英] How can I use :not() without a page or post ID?

查看:46
本文介绍了如何在没有页面或帖子 ID 的情况下使用 :not()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 CSS 应用于所有页面,除了一个页面,这是 :not() 的用武之地.

I wanted the CSS to apply to all the pages except for one, which is where the :not() comes in.

现在的问题是我要排除的页面既不是页面也不是帖子,所以它没有我可以使用的ID;它是由插件创建的页面,原始帖子"实际上是一个属性(我使用了一个属性管理插件,所以当我添加一个属性时,该插件会为其创建一个在网站上可见的页面).我尝试了我能做的一切,但找不到如何选择此页面,即使检查元素将其显示为 post-id-2114.

Now the problem is that the page I want to exclude is neither a page nor a post, so it does not have an ID I can use; it is a page created by a plugin, and the original "post" is actually a property (I use a property management plugin, so when I add a property, the plugin creates a single page for it visible on the website). I tried everything I could but could not find how to select this page, even though the inspect element shows it as post-id-2114.

有没有办法使用 URL 将其从 CSS 中排除?或者其他任何可行的方法?

Is there a way where I could use the URL to exclude it from the CSS? Or anything else that would work?

CSS

.single-property-image-thumb ***:not(.??)*** {
    max-width: 90%;
    margin: auto;
    margin-bottom: -20px;
}

推荐答案

由于上面的评论,如果我理解得很好,我会尝试.

Due to comments above, I try if I understand it well.

/* for all pages */
.single-property-image-thumb {
    max-width: 90%;
    margin: auto;
    margin-bottom: -20px;
}

/* different styles for https://cia-agency.co.uk/property/clifton-court-northwick-terrace-london-nw8/
.postid-2114 is class on body element */
.postid-2114 .single-property-image-thumb {
    /* there will be styles just for linked page  */
    margin-bottom: 0;
}

这篇关于如何在没有页面或帖子 ID 的情况下使用 :not()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆