java--css(2)选择器
来源:互联网 发布:单片机学习 编辑:程序博客网 时间:2024/06/16 20:32
相关语法
样式优先级
由上到下,由外到内。优先级由低到高。——总之,一般情况是以后加载为主,但还有细节优先级问题(后面会讲到)。
CSS代码格式
选择器名称 { 属性名:属性值;属性名:属性值;…….}
属性与属性之间用 分号 隔开
属性与属性值直接按用 冒号 连接
如果一个属性有多个值的话,那么多个值用 空格 隔开。
选择器
就是指定CSS要作用的标签,那个标签的名称就是选择器。意为:选择哪个容器(标签本身就是封装数据的容器)。
选择器共有三种:
1) html标签名选择器。使用的就是html的标签名。
2) class选择器。其实使用的是标签中的class属性。
3) id选择器。其实使用的是标签的中的id属性。
每一个标签都定义了class属性和id属性。用于对标签进行标识,方便对标签进行操作。
在定义的中,多个标签的class属性值可以相同,而id值要唯一,因为JavaScript中经常用。
选择器的优先级
标签名选择器 < class选择器 < id选择器 < style属性
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>我的演示2--css</title> <style type="text/css"> /* 标签选择器 */ div{ color: red; } span { background: #ffff00; } /* 类选择器 */ .c{ background: #79FF79; } /* id选择器 */ #sp1{ background: #7373B9; } #sp2{ background: #7373B9; } </style> <!-- 优先级: id选择器>类选择器>标签选择器 --></head><body> <div class="c">this is text of div1</div> <div>this is text of div2</div> <div>this is text of div3</div> <div class="c">this is text of div4</div> <div>this is text of div5</div> <span >this is text of span0</span><br/> <span >this is text of span1</span><br/> <span class="c" id="sp1">this is text of span2</span><br/> <span id="sp2" style="background: #73BF00">this is text of span3</span><br/> <!-- 优先级: style属性>id选择器 --> <br/> <br/> <br/> <br/> <br/></body></html>
1 0
- java--css(2)选择器
- css-2(css选择器)
- div+css(2)选择器
- 精通css(2)-选择器
- CSS选择器整理2
- css选择器(2)
- CSS选择器2
- CSS基础-23选择器-选择器详解(2)
- CSS基础-2派生选择器
- CSS学习笔记2-选择器
- 【CSS】初识选择器(2)
- CSS笔记2-样式选择器
- CSS 选择器 (1、2、3 )
- css学习之路(2)--css选择器
- CSS学习笔记2:CSS基础选择器
- CSS选择器,jQuery选择器
- jQuery选择器 CSS选择器
- css选择器-基本选择器
- word选中段尾不选回车符
- Gulp+webpack模板化开发演练(1):分离公共头文件
- java.lang.SecurityException: Permission Denial:错误解决办法
- UVA 1331 Minimax Triangulation [最优三角剖分] [dp] [计算几何]
- 使用pthreads基本函数编写helloworld.c
- java--css(2)选择器
- 递归算法的一些实例
- @Autowired学习笔记
- Maven安装
- 如何指定tomcat下的某个项目的具体文件为网站的首页面
- 介绍 Android DropBoxManager Service
- Object-Oriented Analysis and Design Using UML 翻译与学习 (三)
- C++的inline
- IOC的前世今生