zybing 发表于 2013-2-7 17:25:46

CSS几种定义方式

1. 针对标记的定义:
 
 
<style type="text/css">h1{color:red;></style> 这个对页面中的所有h1都起效果
 
2.针对HTML中的某个id
 
<style type="text/css">#title{color:white; background-color:silver;}</style> 对页面中,id为title的标签起效果
 
3.定义一个class
 
<style type="text/css">.title{color:white;}</styel>使用的时候,在页面标签中需要通过<   class="title" >来指定
 
总结:
 
定义方式例子说明不加任何前缀h1{...}对所有h1的标签都发生效果,不需要在页面中指定CSS加##title{...}对id为title的标签起效果,不需要在页面中指定CSS加..title{...}创建一个CSS的class,在页面中要用<    class="title">的方式引用 
 
--------
进一步:指定某个块中的元素属性:
 
#preamble em{color:white;}
这个指定了在:id=preamble块中的em标签的风格
 
 
 
 
 
页: [1]
查看完整版本: CSS几种定义方式