欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

css 属性选择器 - 根据html元素的name属性值选择改元素

程序员文章站 2022-04-06 19:05:48
...

css属性选择器语法:

[attribute=value] 如:[target=-blank] /*选择所有使用target="-blank"的元素*/
或 
[attribute~=value] 如:[title~=flower]  /*选择标题属性包含单词"flower"的所有元素*/
或
[attribute|=language] 如:[lang|=en] /*选择一个lang属性的起始值="EN"的所有元素*/

css属性选择器实例一:

选择所有使用target="_blank"的a元素





The link with target="_blank" gets a yellow background:

manongjc.com disney.com wikipedia.org

Note: For [attribute] to work in IE8 and earlier, a DOCTYPE must be declared.

在线运行

css属性选择器实例二:

选择标题属性包含单词"flower"的所有元素





The image with the title attribute containing the word "flower" gets a yellow border.

css 属性选择器 - 根据html元素的name属性值选择改元素css 属性选择器 - 根据html元素的name属性值选择改元素css 属性选择器 - 根据html元素的name属性值选择改元素

Note: For [attribute~=value] to work in IE8 and earlier, a DOCTYPE must be declared.

在线运行

css属性选择器实例二:

选择一个lang属性的起始值="en"的所有元素





Hello!

Hi!

Ello!

Hi!

Hei!

Note: For [attribute|=value] to work in IE8 and earlier, a DOCTYPE must be declared.

在线运行

相关阅读:

css选择器

相关标签: css属性选择器