📄 ◤css教程_如何在网页中插入css--▃▄ 龙 人 网 络 ▄▃.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0039)http://www.rr365.net/edu-css/css108.htm -->
<HTML><HEAD><TITLE>◤CSS教程.如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃</TITLE>
<META http-equiv=Content-Language content=zh-cn>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="CSS教程,CSS技巧 " name=keywords>
<META
content=网页制作教程:asp教程,ASP.net教程,XML教程,PHP教程,FrontpageXP教程,DreamWeaverMX教程,JSP教程,JavaScript教程,VBScript教程,CSS教程,FrontpageXP,DreamWeaverMX,JSP,JavaScript,VBScript,CSS,asp,ASP.net,XML,PHP相关技巧及资源
name=description><LINK href="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/style.css"
type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.2604" name=GENERATOR></HEAD>
<BODY
onmouseover="window.status='欢迎光临【龙人网站】www.rr365.net,专业服务全为您!!!';return true" ;>
<TABLE id=table1 width="100%">
<TBODY>
<TR>
<TD background="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo4.gif" colSpan=8
height=30> </TD></TR>
<TR>
<TD width=195 height=53><A href="http://www.rr365.net/index.htm"><IMG
height=53 alt=网站优化,网站排名
src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo-up.gif" width=195
border=0></A></TD>
<TD colSpan=7>
<H1 align=center>网页制作教程:CSS教程</H1></TD></TR>
<TR>
<TD background="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo-bt.gif"
height=31>
<P align=center><A
href="http://www.rr365.net/edu-webdesign/index.htm"><FONT
color=#000000>网页制作教程</FONT></A></P></TD>
<TD align=middle bgColor=#e5ecf9><B><A
href="http://www.rr365.net/index.htm">首 页</A></B></TD>
<TD align=middle bgColor=#e5ecf9>
<DIV><B><A
href="http://www.rr365.net/web-promotion.htm">网站推广</A></B></DIV></TD>
<TD align=middle bgColor=#e5ecf9><B><A
href="http://www.rr365.net/webrestruction.htm">网站优化</A></B></TD>
<TD align=middle bgColor=#e5ecf9>
<DIV><B><A
href="http://www.rr365.net/agent/emarketing.htm">轻松代理</A></B></DIV></TD>
<TD align=middle bgColor=#e5ecf9><B><A
href="http://www.rr365.net/webhosting.htm">虚拟主机</A></B></TD>
<TD align=middle bgColor=#e5ecf9>
<DIV><B><A
href="http://www.rr365.net/vpp/domain.htm">域名注册</A></B></DIV></TD>
<TD align=middle bgColor=#e5ecf9><B><A
href="http://www.rr365.net/webdesign.htm">网站建设</A></B></TD></TR></TBODY></TABLE>
<TABLE id=table2 width="100%">
<TBODY>
<TR>
<TD bgColor=#00ccff colSpan=2 height=10> </TD></TR>
<TR>
<TD vAlign=top width="23%" bgColor=#e5ecf9 rowSpan=5>
<P><IMG height=25 src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo6.gif"
width=25 border=0> <B><A href="http://www.rr365.net/edu-css/css.htm"><FONT
color=#ff0000>CSS教程</FONT></A></B></P>
<UL style="FONT-SIZE: 10pt; LINE-HEIGHT: 13pt">
<LI><A href="http://www.rr365.net/edu-css/css.htm">认识CSS</A>
<LI><A href="http://www.rr365.net/edu-css/css102.htm">语法</A>
<LI><A href="http://www.rr365.net/edu-css/css103.htm">伪类—动态链接</A>
<LI><A href="http://www.rr365.net/edu-css/css104.htm">CSS属性</A>
<LI><A href="http://www.rr365.net/edu-css/css105.htm">CSS定位</A>
<LI>
<P style="LINE-HEIGHT: 13pt" align=left><A
href="http://www.rr365.net/edu-css/css106.htm">滤镜</A> </P>
<LI>
<P style="LINE-HEIGHT: 13pt" align=left><A
href="http://www.rr365.net/edu-css/css107.htm">CSS结合JS的运用</A> </P>
<LI>
<P style="LINE-HEIGHT: 13pt" align=left><A
href="http://www.rr365.net/edu-css/css108.htm">如何在网页中插入CSS</A>
</P></LI></UL>
<P><IMG height=25
src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo411.gif" width=25
border=0> <FONT color=#000000><B><A
href="http://www.rr365.net/edu-css/css2.htm"><FONT
color=#008080>CSS技巧</FONT></A></B></FONT></P>
<P><IMG height=25
src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo411.gif" width=25
border=0> <FONT color=#008080><B>CSS相关网站</B></FONT></P>
<UL style="FONT-SIZE: 10pt; LINE-HEIGHT: 13pt">
<LI><A href="http://www.w3.org/Style/CSS/" target=_blank>W3C之CSS规范</A>
<LI><A href="http://www.w3schools.com/css/default.asp" target=_blank>CSS
Tutorial</A> </LI></UL>
<P><IMG height=25
src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/logo411.gif" width=25
border=0> <B><FONT color=#000000><A
href="http://www.rr365.net/edu-css/css4.htm"><FONT
color=#008080>CSS相关软件</FONT></A></FONT></B></P>
<P> </P> </TD>
<TD width="77%">
<UL type=square>
<LI>
<P align=center><U><B><FONT size=4>CSS教程.如何在网页中插入CSS</FONT></B></U></P>
<P align=center><FONT size=4><B> </B></FONT><SPAN
style="FONT-SIZE: 11pt"> </SPAN></P>
<P style="LINE-HEIGHT: 17pt" align=left><SPAN
style="FONT-SIZE: 11pt">
前面我们讲解了CSS的语法,但要想在浏览器中显示出效果,就要让浏览器识别并调用。当浏览器读取样式表时,要依照文本格式来读,这里介绍四种在页面中插入样式表的方法:链入外表样式表、内部样式表、导入外表样式表和内嵌样式。<BR>
1.
链入外部样式表<BR> 链入外部样式表是把样式表保存为一个样式表文件,然后在页面中用<link>标记链接到这个样式表文件,这个<link>标记必须放到页面的<head>区内,如下:<BR> <head><BR> ……<BR> <link
rel="stylesheet" type="text/css"
href="mystyle.css"><BR> ……<BR> </head><BR> 上面这个例子表示浏览器从mystyle.css文件中以文档格式读出定义的样式表。Rel="stylesheet"是指在页面中使用这个外部的样式表。Type="text/css"是指文件的类型是样式表文本。Href="mystyle.css"是文件所在的位置。<BR> 一个外部样式表文件可以应用于多个页面。当你改变这个样式表文件时,所有页面的样式都随之而改变。在制作大量相同样式页面的网站时,非常有用,不仅减少了重复的工作量,而且有利于以后的修改、编辑,浏览时也减少了重复下载代码。<BR> 样式表文件可以用任何文本编辑器(例如:记事本)打开并编辑,一般样式表文件扩展名为.<A
href="http://www.rr365.net/edu-css/css.htm"><FONT
color=#000000>css。</FONT></A>内容是定义的样式表,不包含HTML标记,mystyle.css这个文件的内容如下:<BR> hr
{color: sienna}<BR> p {margin-left: 20px}<BR> body {background-image:
url("images/back40.gif")}<BR> (定义水平线的颜色为土黄;段落左边的空白边距为20象素;页面的背景图片为images目录下的back40.gif文件)<BR> <BR>
2.
内部样式表<BR> 内部样式表是把样式表放到页面的<head>区里,这些定义的样式就应用到页面中了,样式表是用<style>标记插入的,从下例中可以看出<style>标记的用法:<BR> <head><BR> ……<BR> <style
type="text/css"><BR> hr {color: sienna}<BR> p {margin-left:
20px}<BR> body {background-image:
url("images/back40.gif")}<BR> </style><BR> ……<BR> </head><BR> 注意:有些低版本的浏览器不能识别style标记,这意味着低版本的浏览器会忽略style标记里的内容,并把style标记里的内容以文本方式直接显示到页面上。为了避免这样的情况发生,我们用加HTML注释的方式(<!--
注释 -->)隐藏内容而不让它显示:<BR> <head><BR> ……<BR> <style
type="text/css"><BR> <!--<BR> hr {color: sienna}<BR> p
{margin-left: 20px}<BR> body {background-image:
url("images/back40.gif")}<BR> --><BR> </style><BR> ……<BR> </head><BR> <BR>
3.
导入外部样式表<BR> 导入外部样式表是指在内部样式表的<style>里导入一个外部样式表,导入时用@import,看下面这个实例:<BR> <head><BR> ……<BR> <style
type="text/css"><BR> <!--<BR> @import
"mystyle.css"<BR> 其他样式表的声明<BR> --><BR> </style><BR> ……<BR> </head><BR> 上例中@import
“mystyle.css”表示导入mystyle.css样式表,注意使用时外部样式表的路径。方法和链入样式表的方法很相似,但导入外部样式表输入方式更有优势。实质上它是相当于存在内部样式表中的。<BR> 注意:导入外部样式表必须在样式表的开始部分,在其他内部样式表上面。<BR> <BR>
4.
内嵌样式<BR> 内嵌样式是混合在HTML标记里使用的,用这种方法,可以很简单的对某个元素单独定义样式。内嵌样式的使用是直接将在HTML标记里加入style参数。而style参数的内容就是CSS的属性和值,如下例:<BR> <p
style="color: sienna; margin-left:
20px"><BR> 这是一个段落<BR> </p><BR> (这个段落颜色为土黄,左边距为20象素)<BR> 在style参数后面的引号里的内容相当于在样式表大括号里的内容。<BR> 注意:style参数可以应用于任意BODY内的元素(包括BODY本事),除了BASEFONT、PARAM和SCRIPT。<BR> <BR>
5.
多重样式表的叠加<BR> 上一章里我们已经提到样式表的层叠顺序,这里我们讨论插入样式表的这几种方法的叠加,如果在同一个选择器上使用几个不同的样式表时,这个属性值将会叠加几个样式表,遇到冲突的地方会以最后定义的为准。例如,我们首先链入一个外部样式表,其中定义了h3选择符的color
、text-align和font-size属性:<BR> h3 <BR> {<BR> color:
red;<BR> text-align: left;<BR> font-size:
8pt<BR> }<BR> (标题3的文字颜色为红色;向左对齐;文字尺寸为8号字)<BR> 然后在内部样式表里也定义了h3选择符的text-align和font-size属性:<BR> h3
<BR> {<BR> text-align: right; <BR> font-size:
20pt<BR> }<BR> (标题3文字向右对齐;尺寸为20号字)<BR> 那么这个页面叠加后的样式就是:<BR> color:
red; <BR> text-align: right; <BR> font-size:
20pt<BR> (文字颜色为红色;向右对齐;尺寸为20号字)<BR> 字体颜色从外部样式表里保留下来,而对齐方式和字体尺寸都有定义时,按照后定义的优先而依照内部样式表。<BR> 注意:依照后定义的优先,所以优先级最高的是内嵌样式,内部样式表高于导入外部样式表,链入的外部样式表和内部样式表之间是最后定义的优先级高。<BR> </SPAN></P>
<P align=left><BR></P></LI></UL></TD></TR>
<TR>
<TD>
<P
align=center> <A
href="http://www.rr365.net/edu-css/css107.htm">上一节</A></P></TD></TR>
<TR>
<TD>
<HR width="75%" color=#e5ecf9>
<P align=center>网页教程: <A
href="http://www.rr365.net/edu-asp/index.htm">ASP</A>| <A
href="http://www.rr365.net/edu-asp-net/asp-net.htm">ASP.net</A>| <A
href="http://www.rr365.net/edu-xml/xml.htm">XML</A>| <A
href="http://www.rr365.net/edu-php/php.htm">PHP4</A> | <A
href="http://www.rr365.net/edu-frontpage/frontpage.htm">FrontpageXP</A> |
<A
href="http://www.rr365.net/edu-dreamweaver/dreamweaver.htm">DreamWeaverMX</A></P>
<P
align=center>
<A href="http://www.rr365.net/edu-cplus/c.htm">C#</A>| <A
href="http://www.rr365.net/edu-jsp/jsp.htm">JSP</A> | <A
href="http://www.rr365.net/edu-javascript/javascript.htm">JavaScript</A> |
<A href="http://www.rr365.net/edu-vbscript/vbscript.htm">VBScript</A> | <A
href="http://www.rr365.net/edu-css/css.htm">CSS</A></P></TD></TR>
<TR>
<TD>
<HR width="50%" color=#e5ecf9>
<P> </P></TD></TR>
<TR>
<TD>
<FORM name=query0 action=http://www1.baidu.com/baidu method=get
target=_blank>
<DIV align=center><INPUT type=hidden value=baidu name=tn0> <A
href="http://www.baidu.com/"><IMG alt=Baidu
src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/baidu_logo.gif" align=bottom
border=0></A> <INPUT size=15 name=word0> <IFRAME border=0 name=I1
marginWidth=0 marginHeight=0
src="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/help1.htm" frameBorder=no
width=0 scrolling=no height=0></IFRAME><INPUT type=submit value=百度搜索>
</DIV></FORM> </TD></TR></TBODY></TABLE>
<TABLE id=table3 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD style="BORDER-BOTTOM: 1px solid" borderColor=#00ccff height=21> </TD></TR>
<TR>
<TD background="◤CSS教程_如何在网页中插入CSS--▃▄ 龙 人 网 络 ▄▃.files/tdbg.gif"
bgColor=#e5ecf9>
<P align=center><B><A
href="http://www.rr365.net/summary/aboutus.htm">关于我们</A>-<A
href="http://www.rr365.net/summary/paymethod.htm">付款方式</A>-<A
href="http://www.rr365.net/helpcenter/helpcenter.htm">帮助中心</A>-<A
href="http://www.rr365.net/agent/agent.htm">轻松代理</A>-<A
href="http://www.rr365.net/sitemap.htm">网站地图</A>-<A
href="mailto:support@rr365.net">联系我们</A></B></P></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -