您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

CSS的属性选择器使用详解(css入门教程)

2024/5/4 11:17:54发布30次查看
对带有指定属性的 html 元素设置样式。        ( 推荐学习:css入门教程 )
可以为拥有指定属性的 html 元素设置样式,而不仅限于 class 和 id 属性。
注:只有在规定了 !doctype 时,ie7 和 ie8 才支持属性选择器。在 ie6 及更低的版本中,不支持属性选择。
属性选择器
下面的例子为带有 title 属性的所有元素设置样式:
[title]{color:red;}
属性和值选择器
下面的例子为 title="w3school" 的所有元素设置样式:
[title=hello]{border:5px solid blue;}
属性和值选择器 - 多个值
下面的例子为包含指定值的 title 属性的所有元素设置样式。适用于由空格分隔的属性值:
[title~=hello] { color:red; }
下面的例子为带有包含指定值的 lang 属性的所有元素设置样式。适用于由连字符分隔的属性值:
[lang|=en] { color:red; }
设置表单的样式
属性选择器在为不带有 class 或 id 的表单设置样式时特别有用:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html><head><style>input[type="text"]{ width:150px; display:block; margin-bottom:10px; background-color:yellow; font-family: verdana, arial;}input[type="button"]{ width:120px; margin-left:35px; display:block; font-family: verdana, arial;}</style></head><body><form name="input" action="" method="get"><input type="text" name="name" value="bill" size="20"><input type="text" name="name" value="gates" size="20"><input type="button" value="example button"></form></body></html>
以上就是css的属性选择器使用详解(css入门教程)的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product