入门
1.说的容易做不容易
2.css是什么?
网页内容与样式分离
3.如何加载css?
外部加载:
<
head
>
<
link
rel
=
"
stylesheet
"
type
=
"
text/css
"
href
=
"
http://www.dreamdu.com/style.css
"
/>
</
head
>
<
head
>
<
style
type
=
"
text/css
"
>
@import url(http://www.dreamdu.com/style.css);</
style
>
</
head
>
内部加载
<
style
type
=
"
text/css
"
>
<
![CDATA
[
/* ----------文字样式开始---------- */
.dreamdublack16px
{
color:black;
font-size:16px;
}
/* ----------文字样式结束---------- */
]]></
style
>
内联引用
<
p
style
=
"
font-size: 10px; color: #FFFFFF;
"
>
使用CSS内联引用表现段落.
</
p
>
4.css选择器:其实就是以css的名字来区分
标签选择器
类选择器
id选择器
p
{
font-size
:
12px
;
}
.dreamdublue
{
color
:
blue
;
}
#dreamdured
{
color
:
red
;
}
选择器的优先级
优先级最高的最定是行内样式,然后就内联样式,最后就外联样式。 原则一 - 继承不如指定。 原则二 - #ID > .class > 标签选择符。 原则三 - 越具体越强大。 原则四 - 标签#id >#id ; 标签.class > .class。 原则五 - 原则一 > 原则二 > 原则三 > 原则四。