css笔记06:层叠样式选择器
2015-06-30 11:01
786 查看
1.
(1)HTML文件
(2)CSS文件
这里CSS文件中有两个span{},这两个选择器针对性都是1,因此后面的那个优先适用,这导致后面连个<span>元素都是黄色背景
效果图:
(1)HTML文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>选择器</title> 6 <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <p> Specificity is determined by now specific the selector is. <span id="specific"> A specific selector wins</span> over a <span> more general one </span>. </p> <p> Order isn't important until there are one or more elememts of the same specificty referring to the same elememt.In which case,<span> the last one wins</span> </p> </body> </html>
(2)CSS文件
@charset "utf-8"; /* CSS Document */ body { font:Verdana, Geneva, sans-serif; } span#specific { background:pink; } span { background:red; } span { background:yellow; }
这里CSS文件中有两个span{},这两个选择器针对性都是1,因此后面的那个优先适用,这导致后面连个<span>元素都是黄色背景
效果图:
![](http://images0.cnblogs.com/blog2015/757858/201506/301100244622932.jpg)
相关文章推荐
- css圆角和阴影兼容问题(ie7,ie8)
- reset.css
- CSS常用属性
- LESS CSS 框架简介
- 非预期效果CSS集合
- CSS-tips
- css3 鼠标移入移出效果
- 使用SpannableString 修饰TextView的样式
- css hack
- css笔记05:表单
- css笔记04:属性选择器
- IE不支持option的display样式,只能使用remove和add【转】
- css3使用checked伪类隐藏传统的radio和checkbox
- CSS和文档
- css position用法
- 常用CSS样式
- 理解CSS3 transform
- PASSION之CSS3-outline
- 为button设置背景图片,且全无button痕迹的css
- css笔记03:伪类first-child