css - 如何使用CSS隐藏没有类的段落?

标签 css

我有动态页面并包含 div 和段落,例如:

<div class="oe_view_nocontent">
    <p class="oe_view_nocontent_create">
        Click to add a contact in your contacts directory.
    </p>
    <p>
        Odoo helps you easily track all activities related to
        a customer: discussions, history of business opportunities,
        documents, etc.
    </p>
</div>

我正在尝试的是仅显示具有 class="oe_view_nocontent" 的段落并隐藏另一个没有类的段落。

我试图通过使用这些线程来解决问题:

Hide long text except the first two paragraphs

CSS: hide table with no class or id

我试过:

p {
    display: none;
}
p.oe_view_noontent {
  display: div;
}

从这里开始: Can I write a CSS selector selecting elements NOT having a certain class?

我的尝试:

p:not(.class) {
    display: none;
}

但是我没有得到任何东西。我只想要那个

谁有

class="oe_view_nocontent_create"

知道我哪里做错了吗?

最佳答案

我认为,您正在寻找 not:() 选择器

p:not(.oe_view_nocontent_create) {
    display: none;
}

关于css - 如何使用CSS隐藏没有类的段落?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54714433/

相关文章:

javascript - Jquery BxSlider 插件帮助创建自定义左右箭头以浏览幻灯片

c# - 用数据填充大型下拉列表

html - meteor css 动画与之前/之后

html - 无滚动条的可调整大小的背景图像

html - 将下拉选择置于所有 DIV 的前面

html - Bootstrap NavBar 如何更改 Navbar-Brand 类上的文本颜色?

javascript - 用 '.' 填充整个主体的 jQuery 代码

internet-explorer - 有没有办法得到CSS :not() selector working in IE and Chrome?

css - 一侧呈一定 Angular 背景正方形

html - 使背面图像模糊和正面图像清晰可见