简体   繁体   English

CSS属性选择器不起作用 <li> 元件

[英]CSS Attribute selector not working on <li> element

I'm trying to target an <li> tag based on its title attribute but it is having no effect: 我试图基于<li>标签的title属性来定位,但是它没有任何效果:

<style>      
[title~=Client PPT Presentation] {
display: none;
}
</style>
<li title="Client PPT Presentation">
</li>

Title is is a global attribute and I verified sytntax, so why isn't this working? 标题是一个全局属性,我已经验证了语法,为什么这不起作用?

The ~= operator is used to select elements with an attribute value containing a specified word ~=运算符用于选择具有包含指定单词的属性值的元素

Example: 例:

[title~='Client'] {
  display: none;
}

If you want to check for a string value (not a single word) you have to use the *= operator which is used to select elements whose attribute value contains a specified value 如果要检查字符串值(不是单个单词),则必须使用*=运算符,该运算符用于选择属性值包含指定值的元素

[title*='Client PPT Presentation'] {
   display: none;
}

http://jsfiddle.net/ http://jsfiddle.net/

you should select it using [title="Client PPT Presentation"] 您应该使用[title="Client PPT Presentation"]

see http://jsfiddle.net/ngzck7bp/ 看到http://jsfiddle.net/ngzck7bp/

Have you tried: 你有没有尝试过:

<style> 
li[title="Client PPT Presentation"] {
    display: none;
} 
</style>
<li title="Client PPT Presentation">
</li>

I believe this is what you need. 我相信这就是您所需要的。 You should honestly have just read this though. 你应该老老实实刚才读虽然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM