今天的课程加速了,比平时快了些,但觉得很不错。nice~

属性选择符

E[att]       选择具有att属性的E元素。

input[type]{color: #red;}
<input type="radio">

E[att="val"]      选择具有att属性且属性值等于val的E元素。

input[type="radio"]{color: #red;}

<input type="radio">

E[att~="val"]     选择具有att属性且属性值为一用空格分隔的字词列表,其中一个等于val的E元素。

a[class~="ht"]{font-size: 16px;}
<a href="www.baidu.com" class="ht sss"></a>

E[att^="val"]    选择具有att属性且属性值为以val开头的字符串的E元素。

a[href^="www"]{font-size: 16px;}

<a href="www.baidu.com"></a>

E[att$="val"]     选择具有att属性且属性值为以val结尾的字符串的E元素。

input[type$="o"]{color: red;}

<input type="radio">

E[att*="val"]      选择具有att属性且属性值为包含val的字符串的E元素。

input[type*="ad"]{color: red;}

<input type="radio">

E[att|="val"]      选择具有att属性且属性值为以val开头并用连接符"-"分隔的字符串的E元素。

input[class|="te"]{color: red;}

<input type="radio" class="te-ss">

E:first-letter/E::first-letter       设置对象内的第一个字符的样式。

就是匹配的到的元素的第一个字。

E:first-line/E::first-line       设置对象内的第一行的样式。

E:before/E::before          设置在对象前(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用

E:after/E::after              设置在对象后(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用

E::placeholder               设置对象文字占位符的样式。

E::selection                 设置对象被选择时的颜色。

<p class="t1">测试css的伪对象选择符,天气晴朗,阳光明媚!</p>

p.t1{width:100px;border:1px solid black;} /* CSS3的语法改成 ::,原本是: */

p.t1::first-letter {font-size:20px;font-weight:bold;}/*第一个字符*/

p.t1::first-line {color:blue;}/* 第一行 */


css: .t2::before{content:'123';}

.t2::after{content:'123';}

兼容:

html:<input type="search" placeholder="测试">
css:
input::-webkit-input-placeholder {
color: green;} input:-ms-input-placeholder { // IE10+
color: green;} input:-moz-placeholder { // Firefox4-18
color: green;} input::-moz-placeholder { // Firefox19+
color: green;}
 <h3>请使用鼠标选取我</h3>
<p>请使用鼠标选取我</p> p::-moz-selection{ background-color:#E13300; color: white;}
p::selection{ background-color: #E13300; color: white; }

css的样式

font-family    设置文字名称,可以使用多个名称,或者使用逗号 分隔,浏览器则按照先后顺序依次使用可用字体。

p { font-family:‘宋体','黑体', 'Arial’ }

font-size       设置文字的尺寸

注:如果用百分比作为单位,则是基于父元素字体的大小

p { font-size:14px;}    

font-weight       控制字体粗细

p { font-weight:bold;}

font-style       控制字体是否倾斜

p { font-style: normal; }
p { font-style: italic; }
p { font-style: oblique; }

font(字体样式缩写)

font : font-style || font-variant || font-weight || font-size || / line-height || font-family

p { font:italic bold 14px/22px 宋体}

color     控制文本的字体颜色

p{
color:#FF0000;
}

text-decoration(文本装饰线条)      控制文本装饰线条

text-decoration : none || underline || blink || overline || line-through 

p { text-decoration:overline;}

p { text-decoration:underline;}

p { text-decoration:line-through;}

text-shadow(文字阴影)     控制文字的阴影部分。

text-shadow: h-shadow v-shadow blur color;

h-shadow         必需。水平阴影的位置。允许负值。
v-shadow 必需。垂直阴影的位置。允许负值。
blur 可选。模糊的距离。
color 可选。阴影的颜色。 h1{
text-shadow: 2px 2px #ff0000;
}

width   宽度

width : auto | length     

p { width:300px;}

div { width:50%;}

height    高度

height : auto | length 

img { height:200px;}

div { height:100px;}

margin     外边距

margin : auto | length 

margin-top         设置上边的外边距
margin-bottom 设置下边的外边距
margin-left 设置左边的外边距
margin-right 设置右边的外边距 div { width:300px; height:100px; margin:10px;} div { width:300px; height:100px; margin:0 auto;} 缩写型式: margin: 上边距 右边距 下边距 左边距 margin: 上下边距 左右边距 margin: 上边距 左右边距 下边距

padding      内边距

padding : length

div { width:300px; height:100px; padding:10px;}

padding-top         设置上边的内边距
padding-bottom 设置下边的内边距
padding-left 设置左边的内边距
padding-right 设置右边的内边距 缩写型式: padding: 上边距 右边距 下边距 左边距 padding : 上下边距 左右边距 padding : 上边距 左右边距 下边距

补充知识:

padding内边距

当一个盒子设置了背景图像后,默认情况下背景图像覆盖的范围是padding和内容组成的范

围,并以padding的左上角为基准点平铺背景图像。

border边框

border边框里在IE并不显示背景图像的内容,在Firefox则显示背景图像的内容。

因为边框是介于内边距和外边距之间的,当边框设置为虚线时,在IE中,虚线空白的地方露

出来的是padding部分的背景,而在Firefox中,虚线空白的地方露出来的是margin部分的背景。

margin外边距

body是个特殊的盒子,它的背景色会延伸到margin的部分,而其他盒子的背景色只会覆盖“padding+内容

部分”(IE浏览器中)或者“border+padding+内容”部分(Firefox浏览器中)

margin用于控制块与块之间的距离。

倘若将盒子模型比作展览馆里展出的一幅幅画,那么content就是画面本身,padding就是画面与画框之间的留白,

border就是画框,而margin就是画与画之间的距离。

css之属性及剩余的选择符的更多相关文章

  1. CSS第二天总结 更多的选择符

    CSS的选择符非常多,今天继续总结后面的选择符 1.id和class选择符某些情况下我们用关系选择符或者伪类选择符无法选中一些元素时,我们可以给这些元素起 个名字或者分类,这就是id和class属性. ...

  2. CSS 中常用的选择器(选择符)

    一.标签选择器:直接将HTML标签(Tag)作为选择器,可以是p.h1.dl.strong等HTML标签.如: p { font:12px;}em { color:blue;}dl { float:l ...

  3. CSS和html如何结合起来——选择符及优先级

       1.选择符     兼容性 统配选择符 *         元素选择符 body   类选择符 .class   id选择符 #id         包含原则符 p strong     (所有 ...

  4. 3 CSS 定位&浮动&水平对齐&组合选择符&伪类&伪元素

    CSS Position(定位):元素的定位与文档流无关 static定位: HTML元素的默认值, 没有定位,元素出现在正常的流中 静态定位的元素不会受到top,bottom,left,right影 ...

  5. css那些事儿1 css选择符与管理

    结合当下作为一名net程序员,难以找到工作情况下,先学习前端知识,前端现在已成为web和app的一个交叉点,web前端化,app使用h5技术前端化,至于什么后台数据库 缓存 消息队列的路线如果没有大型 ...

  6. css3选择符

    常用的选择符 1.元素选择符 2.id选择符 3.class选择符 4.通配符 5.群组选择符 6.包含选择符 7.伪类选择符(伪类选择符CSS中已经定义好的选择器,不能随便取名) 8.伪对象选择符( ...

  7. CSS属性选择符

    属性选择符: E[att] 选择具有att属性的E元素. <style type="text/css"> a[class]{ background-color: red ...

  8. #8.10.16总结# 属性选择符 伪对象选择符 CSS的常用样式

    属性选择符 E[att] E[att="val"] E[att~="val"] E[att^="val"] E[att$="val ...

  9. css选择符有哪些?哪些属性可以继承?优先级算法如何计算?内联和important哪个优先

    通配选择符* { sRules }  类型选择符E { sRules }  td { font-size:14px; width:120px; }   属性选择符 E [ attr ] { sRule ...

随机推荐

  1. mysql 循环插入日期递增

    create procedure wk() begin declare i int; ; do insert into t (myday) values (date_sub(curdate(),int ...

  2. 自定义安装php开发环境(1)--apache和php整合

    第一步:安装apache 第二步:下载php核心包php-5.3.3-Win32-VC6-x86.zip.并放入开发环境文件夹C:/phpenv/文件夹下 第三步: 将apache 和php 整合 也 ...

  3. Azure IOT (EventHub + Stream Analytics + Table Storage)的使用

    最近研究利用Azure的 Event hub ,Stream Analytics和TableStorage来实现IOT的一个方案, 利用Event hub来采集传感器设备数据值,然后输入到Stream ...

  4. 0909 45作业one

    1.编译原理学什么? 答: 初遇编译原理,我知道编译原理是计算机专业设置的一门重要的专业课程,主要是介绍编译程序构造的一般原理和基本方法.其内容大概包括语言和文法.词法分析.语法分析.语法制导翻译.中 ...

  5. 【Java学习笔记】Map

    Map: 一次添加一对元素,也称为双列集合. 而Collection,一次添加一个元素,称为单列集合. 常用方法: 1.添加 value  put(key,value);        返回前一个与k ...

  6. html及css常用的单词

    string? 字符串 boolean? 布尔数学体系,1,0 node? 节点,结 log? ? 日志,记录 console? 控制台 alert? ? 警报 document? 文档 write? ...

  7. linux 下 jdk+tomcat+mysql 的 jsp 环境搭建

    JDK 在 linux 下安装 1.          把安装文件放在 /opt 下,并执行 [root@localhost opt]# ./jdk-1_5_0_06-linux-i586.bin 并 ...

  8. hdu 1086 You can Solve a Geometry Problem too

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  9. java线程详解(二)

    1,线程安全 先看上一节程序,我们稍微改动一下: //线程安全演示 //火车站有16张票,需要从四个窗口卖出,如果按照上面的多线程实现,程序如下 class Ticket implements Run ...

  10. java中this用法总结

    1,当局部变量和成员变量重名的时候,在方法中使用this表示成员变量以示区分. class Demo{ String str = "这是成员变量"; void fun(String ...