<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>杭州SEO--Wxd's Blog - 学习文章</title><link>http://www.wxd.cc/</link><description> - </description><generator>RainbowSoft Studio Z-Blog 1.8 Spirit Build 80605</generator><language>zh-CN</language><copyright>Copyright &amp;amp;copy;2008 杭州SEO 专注网站推广 网站优化-吴晓棣个人网站 var gaJsHost = ((&amp;quot;https:&amp;quot; == document.location.protocol) ? &amp;quot;https://ssl.&amp;quot; : &amp;quot;http://www.&amp;quot;);document.write(unescape(&amp;quot;%3Cscript src='&amp;quot; + gaJsHost + &amp;quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&amp;quot;));try {var pageTracker = _gat._getTracker(&amp;quot;UA-6867833-1&amp;quot;);pageTracker._trackPageview();} catch(err) {}   浙ICP备08108965号</copyright><pubDate>Wed, 08 Sep 2010 14:37:32 +0800</pubDate><item><title>CSS选择符详解</title><author>wxd@wxd.cc (wxd)</author><link>http://www.wxd.cc/post/css.html</link><pubDate>Tue, 19 Feb 2008 09:50:33 +0800</pubDate><guid>http://www.wxd.cc/post/css.html</guid><description><![CDATA[<div id="textstyle_200906" style="font-size: 9pt"><p>转载的文章，我觉得不错，以前一直没发现CSS还有这么多功能，太汗颜了。记得当初大一学DW的时候为了使一个页面调用两个CSS可是费了不少脑筋，特转此文学习。by wxd</p><p>一、类型选择符</p><p>什么是类型选择符？指以网页中已有的标签类型作为名称的行径符。body是网页中的一个标签类型，div,p,span都是。<br />如下：</p><p>body {}<br />div {}<br />p {}<br />span {}<br /><br />二、群组选择符</p><p>对于XHMTL对象，可以对一组同时进行了相同的样式指派。<br />使用逗号对选择符进行了分隔，这样书写的优点在于同样的样式只需要书写一次即可，减少代码量，改善CSS代码结构。<br />使用时应该注意&quot;逗号&quot;是在半角模式下，并非中文全角模式。<br />如下：</p><p>h1,h2,h6,p,span<br />{<br />font-size:12px;<br />color:#FF0000;<br />font-family: arial;<br />}<br /><br />三、包含选择符<br />对某对象中的子对象进行样式指点定，这样选择方式就发挥了作用。<br />需要注意的是，仅对此对象的子对象标签有效，对于其它单独存在或位于此对象以外的子对象，不应用此样式设置。<br />这样做的优点在于，帮我们避免过多的id、class设置，直接对所需的元素进行定义。<br />如下：</p><p>h2 span<br />{<br />color:red;<br />}<br />如下：<br />body h1 span strong<br />{<br />font-weight:bold;<br />}<br /><br />四、id选择符</p><p>根据DOM文档对象模型原理所出现的选择符，对于一个XHTML文件，其中的每一个标签都可以使用一个id=&quot;&quot;的形式进行一个名称指派，但需要注意，在一个XHTML文件中id是具有唯一性而不可以重复的。<br />在div css布局的网页中，可以针对不同的用途进行命名，如头部为header、底部为footer。<br />XHTML如下：</p><p>&lt;div id=&quot;content&quot;&gt;&lt;/div&gt;<br /><br />CSS如下：</p><p>#content<br />{<br />font-size:14px;<br />line-height:120%;<br />}<br /><br />五、class选择符</p><p>其实id是对于XHTML标签的扩展，而class是对SHTML多个标签的一种组合，class直译的意思是类或类别。<br />对于XHTML标签使用class=&quot;&quot;进行名称指派。与id不同，class可以重复使用，对于多个样式相同的元素，可以直接定义为一个class。<br />使用class的优点已不言自明，它对CSS代码重用性有良好的体现，众多的标签均可以使用一个样式来定义而不需要每一个编写一个样式代码。<br />XHTML如下：</p><p>&lt;p class=&quot;he&quot;&gt;&lt;/p&gt;<br />&lt;span class=&quot;he&quot;&gt;&lt;/span&gt;<br />&lt;h5 class=&quot;he&quot;&gt;&lt;/h5&gt;<br /><br />CSS如下：</p><p>.he<br />{<br />margin:10px;<br />background-color:red;<br />}<br /><br />六、标签指定式的选择符</p><p>如果想同时使用id和class，也想同时使用标签选择符，可以使用如下的方式：</p><p>h1#content {}<br />/*表示所有id为content的h1标签*/<br />h1.p1 {}<br />/*表示所有class为p1的h1标签*/<br /><br />标签指定式选择符的精度介于标签选择符及id/class选择符之间，是常用的选择符之一。</p><p>七、组合选择符</p><p>对于上面的所有选择符而言，进行组合使用。如下：</p><p>h1 .p1 {}<br />/*表示h1下的所有class为p1的标签*/<br />#content h1 {}<br />表示id为content的标签下的所有h1标签<br />h1 .p1,#content h1 {}<br />/*表示h1下的所有class为p1的标签以及id为content的标签下的所有h1标签*/<br />h1#content h2{}<br />/*id为content的h1标签下的h2标签*/<br /><br />CSS选择符是非常自由与灵活的，可以根据页面的需要，使用各种选择符，尽量结构化与优化CSS文件.</p></div>]]></description><category>学习文章</category><comments>http://www.wxd.cc/post/css.html#comment</comments><wfw:comment>http://www.wxd.cc/</wfw:comment><wfw:commentRss>http://www.wxd.cc/feed.asp?cmt=130</wfw:commentRss><trackback:ping>http://www.wxd.cc/cmd.asp?act=tb&amp;id=130&amp;key=7ff3da57</trackback:ping></item></channel></rss>
