<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>等待-放飞梦想 &#187; CSS</title>
	<atom:link href="http://leotheme.cn/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://leotheme.cn</link>
	<description>勤现在-乐将来</description>
	<lastBuildDate>Fri, 03 Feb 2012 12:32:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>使用lesscss来编码编写css</title>
		<link>http://leotheme.cn/javascript/use-lesscss-edit-css.html</link>
		<comments>http://leotheme.cn/javascript/use-lesscss-edit-css.html#comments</comments>
		<pubDate>Sat, 24 Sep 2011 05:10:24 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[lesscss]]></category>
		<category><![CDATA[编缉器]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=958</guid>
		<description><![CDATA[lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。 lesscss使用方法有两种： 页面添加一个 less.js的文件，css使用 style.less 文件后缀来编写，不过需要有服务器的环境支持 &#60;link rel=&#34;stylesheet/less&#34; type=&#34;text/css&#34; href=&#34;styles.less&#34;&#62; &#60;script&#160;src=&#34;less.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; 在服务器端使用node.js来编译，node.js 使用 less的方法如下： 先使用npm包管理器来安装 $ npm install less 然后就可以使用命令行来编译压缩less代码了 $ lessc styles.less > styles.css 下面是一些lesscss的语法： 1、使用变量： // LESS @color: #4D926F; #header&#160;{ &#160; color: @color; } h2&#160;{ &#160; color: @color; } /*&#160;Compiled CSS */ #header&#160;{ &#160; color:&#160;#4D926F; } h2&#160;{ &#160; color:&#160;#4D926F; } 2、组合 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS清除浮动的一些方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-clear-float-fangfa.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS清除浮动的一些方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何使你的CSS样式更易阅读?" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何使你的CSS样式更易阅读?</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。</p>
<p>lesscss使用方法有两种：</p>
<p>页面添加一个 less.js的文件，css使用 style.less 文件后缀来编写，不过需要有服务器的环境支持<br />
<span id="more-958"></span></p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">link</span><span style="color: Gray;"> </span><span style="color: #00008b;">rel</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">stylesheet/less</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/css</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">styles.less</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;</span><span style="color: Green;">script</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">less.js</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/javascript</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">script</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>    在服务器端使用node.js来编译，node.js 使用 less的方法如下：<br />
    先使用npm包管理器来安装<br />
    $ npm install less<br />
    然后就可以使用命令行来编译压缩less代码了<br />
    $ lessc styles.less > styles.css</p>
<p><img src="http://leotheme.cn/wp-content/uploads/2011/09/2011080118002730.jpg" alt="lesscss" title="2011080118002730" width="600" height="220" class="alignnone size-full wp-image-959" /><br />
下面是一些lesscss的语法：</p>
<p>1、使用变量：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Gray;">// </span><span style="color: Blue;">LESS</span></li>
<li><span style="color: #00008b;">@color</span><span style="color: Gray;">: #4</span><span style="color: Blue;">D926F</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;"> @color</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">h2</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;"> @color</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">/</span><span style="color: Blue;">*</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">Compiled</span><span style="color: Gray;"> </span><span style="color: Blue;">CSS</span><span style="color: Gray;"> </span><span style="color: Blue;">*</span><span style="color: Gray;">/</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">#4D926F</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">h2</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">#4D926F</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li></ol></div>
<p>2、组合</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Gray;">// </span><span style="color: Blue;">LESS</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">.rounded-corners</span><span style="color: Gray;"> (</span><span style="color: #00008b;">@radius</span><span style="color: Gray;">: 5</span><span style="color: Blue;">px</span><span style="color: Gray;">) </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-radius:</span><span style="color: Gray;"> @radius</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; -</span><span style="color: Green;">webkit-border-radius:</span><span style="color: Gray;"> @radius</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; -</span><span style="color: Green;">moz-border-radius:</span><span style="color: Gray;"> @radius</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">.rounded-corners</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#footer</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">.rounded-corners</span><span style="color: Gray;">(10</span><span style="color: Blue;">px</span><span style="color: Gray;">);</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">/</span><span style="color: Blue;">*</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">Compiled</span><span style="color: Gray;"> </span><span style="color: Blue;">CSS</span><span style="color: Gray;"> </span><span style="color: Blue;">*</span><span style="color: Gray;">/</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-radius:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">5</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; -</span><span style="color: Green;">webkit-border-radius:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">5</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; -</span><span style="color: Green;">moz-border-radius:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">5</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#footer</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-radius:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; -</span><span style="color: Green;">webkit-border-radius:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; -</span><span style="color: Green;">moz-border-radius:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li></ol></div>
<p>3、选择器</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Gray;">// </span><span style="color: Blue;">LESS</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">h1</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">font-size:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">26</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">font-weight:</span><span style="color: Gray;">&nbsp;</span><span style="color: Red;">bold</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">p</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">font-size:</span><span style="color: Gray;"> </span><span style="color: Maroon;">12</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">a</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">text-decoration:</span><span style="color: Gray;"> </span><span style="color: Red;">none</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &amp;:</span><span style="color: Blue;">hover</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">border-width:</span><span style="color: Gray;"> </span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">/</span><span style="color: Blue;">*</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">Compiled</span><span style="color: Gray;"> </span><span style="color: Blue;">CSS</span><span style="color: Gray;"> </span><span style="color: Blue;">*</span><span style="color: Gray;">/</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">h1</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">font-size:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">26</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">font-weight:</span><span style="color: Gray;">&nbsp;</span><span style="color: Red;">bold</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">p</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">font-size:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">12</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">p</span><span style="color: Gray;"> </span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">text-decoration:</span><span style="color: Gray;">&nbsp;</span><span style="color: Red;">none</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">p</span><span style="color: Gray;"> </span><span style="color: Blue;">a</span><span style="color: Navy;">:hover</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-width:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li></ol></div>
<p>4、变量预算</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Gray;">// </span><span style="color: Blue;">LESS</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #00008b;">@the</span><span style="color: Gray;">-border: 1</span><span style="color: Blue;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: #00008b;">@base</span><span style="color: Gray;">-color: #111;</span></li>
<li><span style="color: #00008b;">@red</span><span style="color: Gray;">:&nbsp; &nbsp; &nbsp; &nbsp; #842210;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;"> @base-color * </span><span style="color: Maroon;">3</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-left:</span><span style="color: Gray;"> @the-border</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-right:</span><span style="color: Gray;"> @the-border * </span><span style="color: Maroon;">2</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#footer</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;"> @base-color + </span><span style="color: #00008b;">#003300</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-color:</span><span style="color: Gray;"> desaturate(@</span><span style="color: #00008b;">red</span><span style="color: Gray;">, </span><span style="color: Maroon;">10</span><span style="color: Red;">%</span><span style="color: Gray;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">/</span><span style="color: Blue;">*</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">Compiled</span><span style="color: Gray;"> </span><span style="color: Blue;">CSS</span><span style="color: Gray;"> </span><span style="color: Blue;">*</span><span style="color: Gray;">/</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">#header</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">#333</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-left:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-right:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">2</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">#footer</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">color:</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">#114411</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">border-color:</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">#7d2717</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li></ol></div>
<p>5、import 外部css</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #00008b;">@import</span><span style="color: Gray;"> &quot;</span><span style="color: Blue;">lib.less</span><span style="color: Gray;">&quot;;</span></li>
<li><span style="color: #00008b;">@import</span><span style="color: Gray;"> &quot;</span><span style="color: Blue;">lib</span><span style="color: Gray;">&quot;;</span></li></ol></div>
<p>通用引用了lesscss，我们就可以将css写得模块化，有更好的阅读性。</p>
<p>首先可以通过 import 讲网站的样式分成 n个模块，当页面需要哪个模块就引用哪个。还可以将css3那些新增的功能定义成类库，由于有函数的功能，那些圆角，阴影之类样式只需要定义一次就可以了。讲页面需要使用到的主要文本，边框，背景色定义成变量给后续样式使用，到时网站风格需要改变，颜色也很好的修改。</p>
<p>我个人觉得先阶段lesscss的不足有：</p>
<blockquote><p>1. css3的样式不能自动补全其他浏览器的hack。<br />
     2.使用nodejs在window系统下的支持不够，不过最近刚刚不久发布了一个nodejs window版，这方面估计在不久的将来会改善<br />
     3.编辑器，ide对lesscss语法缩进支持不够友好。</p></blockquote>
<p>转自&#8211;强记<a href="http://www.cnblogs.com/qiangji/archive/2011/08/01/lesscss.html" target="_blank">《使用lesscss来编码编写css》</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS清除浮动的一些方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-clear-float-fangfa.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS清除浮动的一些方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何使你的CSS样式更易阅读?" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何使你的CSS样式更易阅读?</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li><li>2009-06-18 -- <a href="http://leotheme.cn/javascript/about-css-style.html" title="关于CSS的书写习惯">关于CSS的书写习惯</a> (7)<br /><small>其实每个人都有自己喜欢的书写格式习惯，我在刚学CSS的时候，什么都不知道，只是要实现什么效果，我后就写个ID或类进去。放哪个位置也不管，丢进去就行了。反正效果实现了；后来当需要修改某些地方的时候，才发...</small></li><li>2009-06-03 -- <a href="http://leotheme.cn/javascript/css-auto-for-br.html" title="CSS实现自动换行的小技巧">CSS实现自动换行的小技巧</a> (4)<br /><small>大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！

对于div

1.（IE浏览器）white-space:normal; word-...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/use-lesscss-edit-css.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>左右两栏等高实现方法</title>
		<link>http://leotheme.cn/javascript/css-to-realize-accordant.html</link>
		<comments>http://leotheme.cn/javascript/css-to-realize-accordant.html#comments</comments>
		<pubDate>Wed, 11 Nov 2009 03:21:51 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[左右等高]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=744</guid>
		<description><![CDATA[等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简单，但毕境麻烦。现在有了个更简单的方法。这个方法的原理是事先通过正内边距来使其拥有足够高度，然后通过负外边距来使得其的位置不变。通过给父元素溢出隐藏，我们可以隐藏掉事先占据的足够高的空间。由两列实际的内容高度来决定整个父元素的高度，从而实现了等高。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62; &#60;title&#62;CSS等高布局&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; body { margin: 0; padding: 0; font:14px/1.6em Arial, Helvetica, 宋体,sans-serif; text-align: cnter;} .main { width: 800px; margin: 0 auto; margin-top: 20px; color: #FFF; overflow: hidden;} .left {float: left; width: 550px; background: #f00; border: 1px solid [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="CSS处理斜角导航条的一个例子" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcsschulixiejiaonav.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/23/6202112.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS处理斜角导航条的一个例子</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用jquery写一个简单的菜单伸缩效果" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fjquery-for-nav-slide.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197279.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用jquery写一个简单的菜单伸缩效果</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="给你的侧边栏添加一个登陆入口" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fadd-login-window-at-sidebar.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197290.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">给你的侧边栏添加一个登陆入口</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="未知宽度容器的居中解决方案" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fdom-float-center.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6196464.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">未知宽度容器的居中解决方案</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="一个简单的网页调色板" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fonewebcolorban.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6200580.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">一个简单的网页调色板</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简单，但毕境麻烦。现在有了个更简单的方法。这个方法的原理是事先通过正内边距来使其拥有足够高度，然后通过负外边距来使得其的位置不变。通过给父元素溢出隐藏，我们可以隐藏掉事先占据的足够高的空间。由两列实际的内容高度来决定整个父元素的高度，从而实现了等高。<br />
<span id="more-744"></span></p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_hHFxkF">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;CSS等高布局&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body { margin: 0; padding: 0; font:14px/1.6em Arial, Helvetica, 宋体,sans-serif; text-align: cnter;}
.main { width: 800px; margin: 0 auto; margin-top: 20px; color: #FFF; overflow: hidden;}
.left {float: left; width: 550px; background: #f00; border: 1px solid #666; padding-bottom: 6180px; margin-bottom: -6180px;}
.right {float: right; width: 240px; background: #090; border: 1px solid #666; padding-bottom: 6180px; margin-bottom: -6180px; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;main&quot;&gt;
&lt;div class=&quot;left&quot;&gt;
&lt;p&gt;我很高&lt;/p&gt;
&lt;p&gt;我也很高&lt;/p&gt;
&lt;p&gt;我非常高&lt;/p&gt;
&lt;p&gt;我就是很高&lt;/p&gt;
&lt;p&gt;我很高&lt;/p&gt;
&lt;p&gt;我也很高&lt;/p&gt;
&lt;p&gt;我非常高&lt;/p&gt;
&lt;p&gt;我就是很高&lt;/p&gt;
&lt;p&gt;我很高&lt;/p&gt;
&lt;p&gt;我也很高&lt;/p&gt;
&lt;p&gt;我非常高&lt;/p&gt;
&lt;p&gt;我就是很高&lt;/p&gt;
&lt;p&gt;我很高&lt;/p&gt;
&lt;p&gt;我也很高&lt;/p&gt;
&lt;p&gt;我非常高&lt;/p&gt;
&lt;p&gt;我就是很高&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;right&quot;&gt;
&lt;p&gt;我会和左边一样高吗？&lt;/p&gt;
&lt;p&gt;我和左边一样高哦！&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="U.Code.Run('runcode_hHFxkF');"/> <input type="button" value="复制" class="runcode_button" onclick="U.Code.Copy('runcode_hHFxkF');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>这里考滤到一个意外，就是右边的内容比左边多的时候；其实只需对左右两边都进行正内边距和负外边距设置就行了。这样不管是左边还是右边高，两边的高度始终都是一样的。利用这个原理，我们还可以实现三列多列等高布局。</p>
<p>顺便讲下JQ的实现方法。也很简单，原理就是取得左右两边的高度，然后判断这个值，把大的值赋给小的就行了。看代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: Teal;">document</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">ready</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">_leftheight</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.left</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">_rightheight</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.right</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">_leftheight</span><span style="color: Gray;"> &gt; </span><span style="color: Blue;">_rightheight</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.right</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">(</span><span style="color: Blue;">_leftheight</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">else</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.left</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">(</span><span style="color: Blue;">_rightheight</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">})</span></li></ol></div>
<p>好了，到这里相信大家已经都会了。其实还有一些方法可以实现等高的，比如说背景，大家没事研究研究吧；</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="WordPress主题之Maxthon 2.0.2[08-08-11]" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fwordpress%2Fwordpressthememaxthon202.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6198872.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress主题之Maxthon 2.0.2[08-08-11]</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用jQuery实现个性有序列表" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fjquery-to-sequential-list.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197275.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用jQuery实现个性有序列表</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于Tab(选项卡)的一些实现方式" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabouttabs.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197326.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于Tab(选项卡)的一些实现方式</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="功能强大的FLASH Galleryd——dfGallery 2.0" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fshare%2Fflash-galleryd-dfgallery-20.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197154.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">功能强大的FLASH Galleryd——dfGallery 2.0</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Windows Internet Explorer 8 简体中文正式版" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fnews%2Fwindows-internet-explorer-8.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-to-realize-accordant.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197071.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Windows Internet Explorer 8 简体中文正式版</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li><li>2009-06-18 -- <a href="http://leotheme.cn/javascript/about-css-style.html" title="关于CSS的书写习惯">关于CSS的书写习惯</a> (7)<br /><small>其实每个人都有自己喜欢的书写格式习惯，我在刚学CSS的时候，什么都不知道，只是要实现什么效果，我后就写个ID或类进去。放哪个位置也不管，丢进去就行了。反正效果实现了；后来当需要修改某些地方的时候，才发...</small></li><li>2009-06-03 -- <a href="http://leotheme.cn/javascript/css-auto-for-br.html" title="CSS实现自动换行的小技巧">CSS实现自动换行的小技巧</a> (4)<br /><small>大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！

对于div

1.（IE浏览器）white-space:normal; word-...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/css-to-realize-accordant.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CSS 3.0 参考手册 (中文版)</title>
		<link>http://leotheme.cn/javascript/css-3-0-chm.html</link>
		<comments>http://leotheme.cn/javascript/css-3-0-chm.html#comments</comments>
		<pubDate>Sun, 30 Aug 2009 06:55:34 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3.0手册]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=735</guid>
		<description><![CDATA[作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助你更好的学习和理解CSS3。 CSS 是 Cascading Style Sheet 的缩写。译作「层叠样式表」。是用于(增强)控制网页样式并允许将样式信息与网页内容分离的一种标记性语言。 手册难点 1. 中文资料少，对英文翻译功底要求较高； 2. 基础语法要求字斟句酌，避免产生歧义； 3. 兼容性列表涉及浏览器及版本众多； 4. 草案中的Grid布局被业界同仁普遍认为比“天书”还难… CSS3 还是草案，中文资料少之又少，基本上都是一篇内容转来转去，而我们的手册从基础语法到示例制作，都是根据W3C工作草案进行翻译，并结合自身的沉淀制作示例。 备受期待的 CSS 3 新功能 圆角、多背景、@font-face 用户自定义字体、动画与渐变、渐变色、盒阴影、RGBa &#8211; 加入透明色、文字阴影等等 CSS3 的出现，让代码更简洁、页面结构更合理，性能和效果得到兼顾。 CSS 3.0 参考手册 (中文版) 预览： 下载： CSS 3.0 参考手册 (中文版) 下载 (366k) 相关文章2008-08-24 -- 给你的BLOG添加漂亮的登陆效果 (8)不知道大家的对WP的登陆是怎么看的，反正我是很不喜欢点个链接到另一个页面去登陆的这种做法。嘿嘿今天给大家带来点小东西，放弃WP默认的登陆方式，打了更加人性化更加酷的登陆方式。同时，由这篇文章开始，引入...2008-08-20 -- Maxthon v1.0[最新修改] (8) Maxthon v1.0[最新修改] 1.对所有代码进一步优化，去掉了作品展示部分。 [详细]：对CSS代码进一步优化。和重组，打开后能发现现的在CSS变得很干净。方便大家修改...2008-08-15 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何使你的CSS样式更易阅读?" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何使你的CSS样式更易阅读?</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于CSS的书写习惯" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于CSS的书写习惯</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS实现自动换行的小技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS实现自动换行的小技巧</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的<a href="http://webteam.tencent.com/css3/">webteam</a>发布的CSS 3.0 参考手册 (中文版)将有助你更好的学习和理解CSS3。<br />
CSS 是 Cascading Style Sheet 的缩写。译作「层叠样式表」。是用于(增强)控制网页样式并允许将样式信息与网页内容分离的一种标记性语言。</p>
<p><span id="more-735"></span><br />
<strong>手册难点</strong></p>
<p>1. 中文资料少，对英文翻译功底要求较高；<br />
2. 基础语法要求字斟句酌，避免产生歧义；<br />
3. 兼容性列表涉及浏览器及版本众多；<br />
4. 草案中的Grid布局被业界同仁普遍认为比“天书”还难… </p>
<p>CSS3 还是草案，中文资料少之又少，基本上都是一篇内容转来转去，而我们的手册从基础语法到示例制作，都是根据W3C工作草案进行翻译，并结合自身的沉淀制作示例。</p>
<p><strong>备受期待的 CSS 3 新功能</strong></p>
<p>圆角、多背景、@font-face 用户自定义字体、动画与渐变、渐变色、盒阴影、RGBa &#8211; 加入透明色、文字阴影等等<br />
CSS3 的出现，让代码更简洁、页面结构更合理，性能和效果得到兼顾。</p>
<p><strong>CSS 3.0 参考手册 (中文版) 预览：</strong></p>
<p><img src="http://leotheme.cn/wp-content/uploads/2009/08/css3_scrn-500x792.png" alt="css3_scrn" title="css3_scrn" width="500" height="792" class="alignnone size-large wp-image-736" /></p>
<p><strong>下载：</strong></p>
<p><a href="http://webteam.tencent.com/css3/css3.0manual.chm.zip">CSS 3.0 参考手册 (中文版) 下载 (366k)</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何使你的CSS样式更易阅读?" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何使你的CSS样式更易阅读?</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于CSS的书写习惯" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于CSS的书写习惯</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS实现自动换行的小技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS实现自动换行的小技巧</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2008-08-24 -- <a href="http://leotheme.cn/wordpress/geinideblogtianjialogin.html" title="给你的BLOG添加漂亮的登陆效果">给你的BLOG添加漂亮的登陆效果</a> (8)<br /><small>不知道大家的对WP的登陆是怎么看的，反正我是很不喜欢点个链接到另一个页面去登陆的这种做法。嘿嘿今天给大家带来点小东西，放弃WP默认的登陆方式，打了更加人性化更加酷的登陆方式。同时，由这篇文章开始，引入...</small></li><li>2008-08-20 -- <a href="http://leotheme.cn/wordpress/maxthonv10new.html" title="Maxthon v1.0[最新修改]">Maxthon v1.0[最新修改]</a> (8)<br /><small>

Maxthon v1.0[最新修改]

1.对所有代码进一步优化，去掉了作品展示部分。

  [详细]：对CSS代码进一步优化。和重组，打开后能发现现的在CSS变得很干净。方便大家修改...</small></li><li>2008-08-15 -- <a href="http://leotheme.cn/javascript/quediaolinksdesxk.html" title="去掉链接时虚线框的几个方法">去掉链接时虚线框的几个方法</a> (5)<br /><small>我想很多朋友都遇到这个问题，当点击一个链接的时候，总会出现一个虚线框。
在这介绍几种去除的方法：
1.直接给链接加是onfocus="this.blur()".
链接
2.CSS实现

...</small></li><li>2008-08-14 -- <a href="http://leotheme.cn/wordpress/javascriptwordpress.html" title="JavaScript实现WordPress自由颜色主题切换">JavaScript实现WordPress自由颜色主题切换</a> (2)<br /><small>关于自由切换颜色的主题目前有些主题自带这个功能了见下图：



现在来谈谈怎么实现这样一个功能。其实很简单的。不管是换颜色和主题，原理都是一样的，即通个调用不同的CSS来替换掉当前的CSS而实...</small></li><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/css-3-0-chm.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>如何使你的CSS样式更易阅读?</title>
		<link>http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html</link>
		<comments>http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html#comments</comments>
		<pubDate>Tue, 07 Jul 2009 07:47:19 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[主题]]></category>
		<category><![CDATA[样式]]></category>
		<category><![CDATA[用户体验]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=714</guid>
		<description><![CDATA[在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更能够按自己的想法去表现。这样就必须通过修改CSS来完成；那么——样式的易阅性在这个时候很重要。对于一个不是很精通CSS的人来说，怎样使他能够简单、方便的修改CSS成了很重要的一环。 如果CSS的类别名称和排版都很乱。那修改起来是一件非常痛苦的事情。看下面这段CSS样式： .blf1 li {margin:15px 0 10px;padding:10px;border:1px solid #A6C9E1;} 你能很清楚的知道这个样式是针对哪个写的吗？我想除了写的人，不会有人知道了；就算是写得人，一个月后他自己也许也不知道了！再看下面这个： .commentlist li { &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; margin:&#160;15px 0 10px; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; padding:&#160;10px; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; border:&#160;1px solid #A6C9E1; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS清除浮动的一些方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-clear-float-fangfa.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS清除浮动的一些方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS实现自动换行的小技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS实现自动换行的小技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于CSS的书写习惯" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于CSS的书写习惯</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在做<a href="http://www.wordpress.org/">wordpress</a>主题的时候，样式是最重要的一部分。作为<a href="http://leotheme.cn/themes">主题</a>的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更能够按自己的想法去表现。这样就必须通过修改CSS来完成；那么——样式的易阅性在这个时候很重要。对于一个不是很精通CSS的人来说，怎样使他能够简单、方便的修改CSS成了很重要的一环。<br />
<span id="more-714"></span>如果CSS的类别名称和排版都很乱。那修改起来是一件非常痛苦的事情。看下面这段CSS样式：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">.blf1</span><span style="color: Gray;"> </span><span style="color: Blue;">li</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Green;">margin:</span><span style="color: Maroon;">15</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Maroon;">0</span><span style="color: Gray;"> </span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;</span><span style="color: Green;">padding:</span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;</span><span style="color: Green;">border:</span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Red;">solid</span><span style="color: Gray;"> </span><span style="color: #00008b;">#A6C9E1</span><span style="color: Green;"></span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></div></div>
<p>你能很清楚的知道这个样式是针对哪个写的吗？我想除了写的人，不会有人知道了；就算是写得人，一个月后他自己也许也不知道了！再看下面这个：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">.commentlist</span><span style="color: Gray;"> </span><span style="color: Blue;">li</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: Green;">margin:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">15</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Maroon;">0</span><span style="color: Gray;"> </span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: Green;">padding:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: Green;">border:</span><span style="color: Gray;">&nbsp;</span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Red;">solid</span><span style="color: Gray;"> </span><span style="color: #00008b;">#A6C9E1</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: Green;">list-style:</span><span style="color: Gray;">&nbsp;</span><span style="color: Red;">none</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li></ol></div>
<p>这个我想了解WP主题的人都知道这个样式是针对评论列表的LI写的吧。</p>
<p>从上面的例子可以看出，要使CSS更易阅读，合理的元素描述和清晰的格式很重要。我在前面已经写过一篇“<a href="http://leotheme.cn/javascript/about-css-style.html">关于CSS的书写习惯</a>”，简单地介绍了关于自己的CSS书写格式。接下来讲下如何选择合适的、有意义的元素描述内容，从而使得它更易阅读。<br />
不知道大家对于blog的标题和描述是怎么命名的？我个人觉得下面这样的描述是最合理的。</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">.blog-title</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">color:</span><span style="color: Gray;"> </span><span style="color: #00008b;">#060</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">.blog-description</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">color:</span><span style="color: Gray;"> </span><span style="color: #00008b;">#369</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Olive;">}</span></div></div>
<p>我相信大家应该能理解，这个名称是应用于博客的标题和描述。无论您的设计改变了多少次都不会改变。我在这里只是作抛砖引玉。相信大家能够举一反三，写出易读、美观的CSS样式。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS清除浮动的一些方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-clear-float-fangfa.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS清除浮动的一些方法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS实现自动换行的小技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS实现自动换行的小技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于CSS的书写习惯" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于CSS的书写习惯</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2011-09-01 -- <a href="http://leotheme.cn/wordpress/wordpress-themes-perfct.html" title="WordPress主题：perfct 1.0">WordPress主题：perfct 1.0</a> (88)<br /><small>已经很久很久没写日志了。更不知道有多久没有发布新主题了！好像已经失去了那种曾经的兴趣和动力，很多时候想写，却又找不到话题。有些技术上的文章想分享。但又懒得编缉。要分析，上代码，做实例。最终只是想想而已...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-06-18 -- <a href="http://leotheme.cn/javascript/about-css-style.html" title="关于CSS的书写习惯">关于CSS的书写习惯</a> (7)<br /><small>其实每个人都有自己喜欢的书写格式习惯，我在刚学CSS的时候，什么都不知道，只是要实现什么效果，我后就写个ID或类进去。放哪个位置也不管，丢进去就行了。反正效果实现了；后来当需要修改某些地方的时候，才发...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>关于CSS的书写习惯</title>
		<link>http://leotheme.cn/javascript/about-css-style.html</link>
		<comments>http://leotheme.cn/javascript/about-css-style.html#comments</comments>
		<pubDate>Thu, 18 Jun 2009 06:29:32 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css样式]]></category>
		<category><![CDATA[习惯]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=656</guid>
		<description><![CDATA[其实每个人都有自己喜欢的书写格式习惯，我在刚学CSS的时候，什么都不知道，只是要实现什么效果，我后就写个ID或类进去。放哪个位置也不管，丢进去就行了。反正效果实现了；后来当需要修改某些地方的时候，才发现这个问题的严重性。代码混乱，ID，CLASS乱用。不易阅读&#8230;使得修改起来很费劲。 后来开始做wordpress主题的时候，慢慢改变了这种坏习惯。在Maxthon主题的样式中，适当的划分了一下各个部分。 如header，content，sidebar，footer，othes&#8230;然后把样式的属性写在一行里。并且用层叠来定义CSS的作用域。就像下面这样： #content { float: left;&#160; width: 524px;}&#160;#content .post { text-align: left; margin-bottom: 8px;}#content .post .post_title { margin: 10px; }#content .post .post_title p { margin-top: 8px; }#content .post .post_title .abbr { cursor: help;&#160; }#content .post .post_info { line-height: 20px; border-top: 3px solid #DDDDDD; } 这种写法看起来清晰，容易阅读。但同时也增加了很多无用的代码，从而使整个文件的大小增加了。 而我最新发布的Dreamy主题的样式又换了种书写格式；这也是我目前认为最好的书写格式。 /*Comment------------------------------------------------*/.commentlist li {&#160;&#160; &#160; &#160; &#160; &#160; &#160;margin: [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何使你的CSS样式更易阅读?" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fnuheshienide-css-gengyiyuedui.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何使你的CSS样式更易阅读?</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-style.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>其实每个人都有自己喜欢的书写格式习惯，我在刚学CSS的时候，什么都不知道，只是要实现什么效果，我后就写个ID或类进去。放哪个位置也不管，丢进去就行了。反正效果实现了；后来当需要修改某些地方的时候，才发现这个问题的严重性。代码混乱，ID，CLASS乱用。不易阅读&#8230;使得修改起来很费劲。<br />
后来开始做wordpress主题的时候，慢慢改变了这种坏习惯。在Maxthon主题的样式中，适当的划分了一下各个部分。<br />
<span id="more-656"></span><br />
如header，content，sidebar，footer，othes&#8230;然后把样式的属性写在一行里。并且用层叠来定义CSS的作用域。就像下面这样：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">#content</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">float:</span><span style="color: Gray;"> </span><span style="color: Red;">left</span><span style="color: Green;"></span><span style="color: Gray;">;&nbsp; </span><span style="color: Green;">width:</span><span style="color: Gray;"> </span><span style="color: Maroon;">524</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;<br /></span><span style="color: Blue;">#content</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">text-align:</span><span style="color: Gray;"> </span><span style="color: Red;">left</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Green;">margin-bottom:</span><span style="color: Gray;"> </span><span style="color: Maroon;">8</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">#content</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;">_</span><span style="color: Blue;">title</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">margin:</span><span style="color: Gray;"> </span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">#content</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;">_</span><span style="color: Blue;">title</span><span style="color: Gray;"> </span><span style="color: Blue;">p</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">margin-top:</span><span style="color: Gray;"> </span><span style="color: Maroon;">8</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">#content</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;">_</span><span style="color: Blue;">title</span><span style="color: Gray;"> </span><span style="color: Blue;">.abbr</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">cursor:</span><span style="color: Gray;"> </span><span style="color: Red;">help</span><span style="color: Green;"></span><span style="color: Gray;">;&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">#content</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;"> </span><span style="color: Blue;">.post</span><span style="color: Gray;">_</span><span style="color: Blue;">info</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Green;">line-height:</span><span style="color: Gray;"> </span><span style="color: Maroon;">20</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Green;">border-top:</span><span style="color: Gray;"> </span><span style="color: Maroon;">3</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Red;">solid</span><span style="color: Gray;"> </span><span style="color: #00008b;">#DDDDDD</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Olive;">}</span></div></div>
<p>这种写法看起来清晰，容易阅读。但同时也增加了很多无用的代码，从而使整个文件的大小增加了。<br />
而我最新发布的Dreamy主题的样式又换了种书写格式；这也是我目前认为最好的书写格式。</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">/</span><span style="color: Blue;">*Comment</span><span style="color: Gray;"><br />------------------------------------------------</span><span style="color: Blue;">*</span><span style="color: Gray;">/<br /></span><span style="color: Blue;">.commentlist</span><span style="color: Gray;"> </span><span style="color: Blue;">li</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">margin:</span><span style="color: Gray;"> </span><span style="color: Maroon;">15</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Maroon;">0</span><span style="color: Gray;"> </span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">padding:</span><span style="color: Gray;"> </span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">list-style:</span><span style="color: Gray;"> </span><span style="color: Red;">none</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">border:</span><span style="color: Gray;"> </span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Red;">solid</span><span style="color: Gray;"> </span><span style="color: #00008b;">#A6C9E1</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;<br /></span><span style="color: Blue;">.commentlist</span><span style="color: Gray;"> </span><span style="color: Blue;">li</span><span style="color: Gray;"> </span><span style="color: Blue;">.avatar</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">padding:</span><span style="color: Gray;"> </span><span style="color: Maroon;">4</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Maroon;">9</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Maroon;">4</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Maroon;">4</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">float:</span><span style="color: Gray;"> </span><span style="color: Red;">left</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">margin-right:</span><span style="color: Gray;"> </span><span style="color: Maroon;">10</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">background:</span><span style="color: Gray;"> url(images/bgAvatar.png) </span><span style="color: Red;">no-repeat</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">.commentlist</span><span style="color: Gray;"> </span><span style="color: Blue;">li.odd</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">background:</span><span style="color: Gray;"> </span><span style="color: #00008b;">#EFF6F9</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">.commentlist</span><span style="color: Gray;"> </span><span style="color: Blue;">li</span><span style="color: Gray;"> </span><span style="color: Blue;">.byuser</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">background:</span><span style="color: Gray;"> </span><span style="color: #00008b;">#CBEAF4</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">border:</span><span style="color: Gray;"> </span><span style="color: Maroon;">1</span><span style="color: Red;">px</span><span style="color: Gray;"> </span><span style="color: Red;">solid</span><span style="color: Gray;"> </span><span style="color: #00008b;">#A6C9E1</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span></div></div>
<p>总结下几点经验</p>
<p>1. 样式的命名：<br />
   这个其实有些参考资料的。在这里说下我的书写习惯，以前是喜欢用class-name来命名。后来又改成class_name，再到现在改用className这样的方式；其实用className这种方式有个问题，就是大小写很敏感，一定要注意。比如你定义了一个 .postInfo {} ，而你在结构里用 class=”postinfo” 来调用这个类的时候可能不会起作用。建议大家用class_name的格式，我只是个人喜欢后面的这种格式而已。</p>
<p>2. ID和CLASS的使用：<br />
   我现在基本很少用ID来命名了，除了头部的#header,#Container,#sidebar,#footer基本上没特殊情况不用ID，因为ID的优先级很高。有时候会出现一些很麻烦的问题，而且ID要留给JS用，以符合行为与表现分离的原则。</p>
<p>3. 空格的使用<br />
   有些人在写样式时不喜欢空格，其实适当的空格能增强代码的阅读性。<br />
   .className{width:500px;height:300px;}<br />
    .className { width: 500px; height: 300px; }<br />
    你觉得上面那行的阅读性更好？</p>
<p>4. 适当的层叠或缩进定义CSS的“作用域”<br />
   如果你想让首页的title和单篇日志的title不同，比如首页文章的标题是向居左的。单篇日志的标题是居中的。你可以这样写<br />
   .post .title { text-align: left; }<br />
    .singlePost .title { text-align: center; }<br />
    而有时候用层叠会增加代码优先级，所以也可以用缩进来“象征性的”体现作用域。像这样：<br />
   .post { text-align: left; }<br />
            .singleTitle { text-align: center; }</p>
<p>5. CSS HACK<br />
    在一开始的时候，会经常用到Hack来解决一些兼容问题。慢慢就成了种习惯，而这种习惯事实上是不好的。我们应该尽量地少用不用Hack，当然这就要求你对CSS必须相当的熟练。这种东西还是要靠大家在实践中去掌握。在我最新发布的Dreamy 2.0中就没用用到一处Hack。因为很多时候，只要肯思考，换种角度去解决问题。就不必全依赖Hack了。当然，这不代表就不能用Hack了。Hack有时候还是个很好的东西的，这里就不说有哪些Hack技巧了，大家可以自己去搜索下相关资料。建议大家写Hack的时候，把Hack单独写出来。<br />
   一个简单的例子，在处理IE6浮动双边距问题时一般会这样写“<br />
   .post  {<br />
               float: left;<br />
               margin-left: 10px;<br />
               display: inline;<br />
             }<br />
     建议在家写成这样：<br />
   .post {<br />
              float: left;<br />
              margin-left: 10px;<br />
            }<br />
           .post { _display: inline; }/*Hack for IE6*/</p>
<p>对于CSS的书写格式，大家有什么好的建议，欢迎在下面评论。很乐意和大家一起探讨。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li><li>2009-06-03 -- <a href="http://leotheme.cn/javascript/css-auto-for-br.html" title="CSS实现自动换行的小技巧">CSS实现自动换行的小技巧</a> (4)<br /><small>大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！

对于div

1.（IE浏览器）white-space:normal; word-...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/about-css-style.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CSS实现自动换行的小技巧</title>
		<link>http://leotheme.cn/javascript/css-auto-for-br.html</link>
		<comments>http://leotheme.cn/javascript/css-auto-for-br.html#comments</comments>
		<pubDate>Wed, 03 Jun 2009 06:12:07 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[换行]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=524</guid>
		<description><![CDATA[大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！ 对于div 1.（IE浏览器）white-space:normal; word-break:break-all;这里前者是遵循标准。 #wrap{white-space:normal; width:200px; }或者#wrap{word-break:break-all;width:200px;}&#60;div id=&#34;wrap&#34;&#62;ddd111111111111111111111111111111&#60;/div&#62; 效果：可以实现换行 2.（Firefox浏览器）white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法，只能隐藏或者加滚动条，当然不加滚动条效果更好！ #wrap{white-space:normal; width:200px; overflow:auto;}或者#wrap{word-break:break-all;width:200px; overflow:auto; } &#60;div id=&#34;wrap&#34;&#62;ddd1111111111111111111111111111111111111111&#60;/div&#62; 效果：容器正常，内容隐藏 对于table 1. (IE浏览器)使用样式table-layout:fixed； &#60;style&#62;.tb{table-layout:fixed}&#60;/style&#62;&#60;table class=&#34;tbl&#34; width=&#34;80&#34;&#62;&#60;tr&#62;&#60;td&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 效果：可以换行 2.(IE浏览器)使用样式 &#60;style&#62;.tb {table-layout:fixed}&#60;/style&#62;&#60;table class=&#34;tb&#34; width=&#34;80&#34;&#62;&#60;tr&#62;&#60;td nowrap&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 效果：可以换行 3. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap &#60;style&#62;.tb{table-layout:fixed}&#60;/style&#62;&#60;table class=&#34;tb&#34; width=80&#62;&#60;tr&#62;&#60;td width=25% nowrap&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;td nowrap&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 效果：两个td均正常换行 4.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div &#60;style&#62;.tb {table-layout:fixed}.td {overflow:hidden;}&#60;/style&#62;&#60;table class=tb width=80&#62;&#60;tr&#62;&#60;td width=25% class=td [...]]]></description>
			<content:encoded><![CDATA[<p>大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！</p>
<p><strong>对于div</strong></p>
<p>1.（IE浏览器）white-space:normal; word-break:break-all;这里前者是遵循标准。</p>
<p><span id="more-524"></span></p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">#wrap{white-space:normal; width:200px; }<br />或者<br />#wrap{word-break:break-all;width:200px;}<br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">wrap</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">ddd111111111111111111111111111111</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：可以实现换行</p>
<p>2.（Firefox浏览器）white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法，只能隐藏或者加滚动条，当然不加滚动条效果更好！</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">#wrap{white-space:normal; width:200px; overflow:auto;}<br />或者<br />#wrap{word-break:break-all;width:200px; overflow:auto; } <br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">wrap</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">ddd1111111111111111111111111111111111111111</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：容器正常，内容隐藏</p>
<p><strong>对于table</strong></p>
<p>1. (IE浏览器)使用样式table-layout:fixed；</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb{table-layout:fixed}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tbl</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">80</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />abcdefghigklmnopqrstuvwxyz 1234567890<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：可以换行</p>
<p>2.(IE浏览器)使用样式</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb {table-layout:fixed}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tb</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">80</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />abcdefghigklmnopqrstuvwxyz 1234567890<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：可以换行</p>
<p>3. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb{table-layout:fixed}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tb</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">80</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">25</span><span style="color: Gray;">% </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />abcdefghigklmnopqrstuvwxyz 1234567890<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">abcdefghigklmnopqrstuvwxyz 1234567890</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：两个td均正常换行</p>
<p>4.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb {table-layout:fixed}<br />.td {overflow:hidden;}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #00008b;">tb</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">80</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">25</span><span style="color: Gray;">% </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #00008b;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">abcdefghigklmnopqrstuvwxyz 1234567890</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #00008b;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">abcdefghigklmnopqrstuvwxyz 1234567890</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>这里单元格宽度一定要用百分比定义 效果：正常显示，但不能换行。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2010-08-10 -- <a href="http://leotheme.cn/javascript/firefox-and-ie-javascript.html" title="firefox与ie 的javascript区别">firefox与ie 的javascript区别</a> (19)<br /><small>浏览器的兼容问题目前还是一个头痛的问题。除了CSS的兼容性，Javascript的兼容有时候更容易让人头痛。下面收集的一些关于Firefox和IE的区别作个记号，需要的时候看看

1. Docum...</small></li><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/css-auto-for-br.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS清除浮动的一些方法</title>
		<link>http://leotheme.cn/javascript/css-clear-float-fangfa.html</link>
		<comments>http://leotheme.cn/javascript/css-clear-float-fangfa.html#comments</comments>
		<pubDate>Tue, 25 Nov 2008 03:48:49 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[clear]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[浮动]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=217</guid>
		<description><![CDATA[CSS的浮动为我们的布局带来了很大的好处，利用浮动我们可以很方便的写出各种版式。但浮动同时也带来很多问题；这些问题基本上都因为没有及时的或者在适当的位置清楚浮动。下面来说下常用的清除浮动方法： 一：用空标签 这是最常见的一种方法了。通过一个内容为空的标签来清除浮动。这个标签可以是DIV、P、Hr&#8230;。理论上可以是任何标签。 这种方式是在需要清除浮动的父级元素内部的所有浮动元素后添加这样一个标签清楚浮动，并为其定义CSS代码：clear:both。这种方法的弊端在于增加了无意义的结构元素。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head profile=&#34;http://gmpg.org/xfn/11&#34;&#62; &#60;title&#62;CSS清除浮动的一些方法&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; &#60;!-- *{margin:0;padding:0;} body{font:36px bold; color:#F00; text-align:center;} #layout{background:#FFC;} #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} .clear{clear:both;} --&#62; &#60;/style&#62; &#60;/head&#62; &#60;body&#62; &#60;div id=&#34;layout&#34;&#62; &#60;div id=&#34;left&#34;&#62;Left&#60;/div&#62; &#60;div id=&#34;right&#34;&#62;Right&#60;/div&#62; &#60;div class=&#34;clear&#34;&#62;&#60;/div&#62; &#60;/div&#62; &#60;/body&#62; &#60;/html&#62; 提示：你可以先修改部分代码再运行。 二：使用overflow属性 这种方法有效地解决了通过添加空标签元素清除浮动而不得不增加无意代码的弊端。使用该方法是只需在需要清除浮动的元素中定义CSS属性：”overflow:auto”，即可！为了兼容IE6同时要加上”zoom:1&#8243;。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>CSS的浮动为我们的布局带来了很大的好处，利用浮动我们可以很方便的写出各种版式。但浮动同时也带来很多问题；这些问题基本上都因为没有及时的或者在适当的位置清楚浮动。下面来说下常用的清除浮动方法：</p>
<p><strong>一：用空标签</strong></p>
<p>这是最常见的一种方法了。通过一个内容为空的标签来清除浮动。这个标签可以是DIV、P、Hr&#8230;。理论上可以是任何标签。<br />
<span id="more-217"></span><br />
这种方式是在需要清除浮动的父级元素内部的所有浮动元素后添加这样一个标签清楚浮动，并为其定义CSS代码：clear:both。这种方法的弊端在于增加了无意义的结构元素。 </p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_iJKYmQ">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;
&lt;title&gt;CSS清除浮动的一些方法&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
    *{margin:0;padding:0;}
    body{font:36px bold; color:#F00; text-align:center;}
    #layout{background:#FFC;}
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
    .clear{clear:both;}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="U.Code.Run('runcode_iJKYmQ');"/> <input type="button" value="复制" class="runcode_button" onclick="U.Code.Copy('runcode_iJKYmQ');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>二：使用overflow属性</strong></p>
<p>这种方法有效地解决了通过添加空标签元素清除浮动而不得不增加无意代码的弊端。使用该方法是只需在需要清除浮动的元素中定义CSS属性：”overflow:auto”，即可！为了兼容IE6同时要加上”zoom:1&#8243;。</p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_bBoPfE">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;
&lt;title&gt;CSS清除浮动的一些方法&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
    *{margin:0;padding:0;}
    body{font:36px bold; color:#F00; text-align:center;}
    #layout{background:#FF9;overflow:auto;zoom:1;}
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="U.Code.Run('runcode_bBoPfE');"/> <input type="button" value="复制" class="runcode_button" onclick="U.Code.Copy('runcode_bBoPfE');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>三：使用after伪对象清楚浮动。</strong></p>
<p>该方法只适用于非IE浏览器。具体写法可参照以下示例。<br />
使用中需注意以下几点:</p>
<ol>
<li>该方法中必须为需要清除浮动元素的伪对象中设置height:0，否则该元素会比实际高出若干像素；</li>
<li>content属性是必须的，但其值可以为空，蓝色理想讨论该方法的时候content属性的值设为”.”，但我发现为空亦是可以的</li>
</ol>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_o6EHpX">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;
&lt;title&gt;CSS清除浮动的一些方法&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
    *{margin:0;padding:0;}
    body{font:36px bold; color:#F00; text-align:center;}
    #layout{background:#FF9;}
    #layout:after{display:block;clear:both;content:&quot;&quot;;visibility:hidden;height:0;}
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="U.Code.Run('runcode_o6EHpX');"/> <input type="button" value="复制" class="runcode_button" onclick="U.Code.Copy('runcode_o6EHpX');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>PS：第三种方法请在FF下测试。大家都用哪种方法呢?</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2011-02-17 -- <a href="http://leotheme.cn/javascript/dom-float-center.html" title="未知宽度容器的居中解决方案">未知宽度容器的居中解决方案</a> (13)<br /><small>
如上图所示的分页，其结构如下：


	
		1/18
		上一页
		1
		2
		3
		...
		18
		下一页
	



在这个结构中，“.pagena...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/css-clear-float-fangfa.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>增强用户体验之文章内的链接</title>
		<link>http://leotheme.cn/javascript/zq-ued-of-links.html</link>
		<comments>http://leotheme.cn/javascript/zq-ued-of-links.html#comments</comments>
		<pubDate>Thu, 20 Nov 2008 04:54:27 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[选择器]]></category>
		<category><![CDATA[链接]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=192</guid>
		<description><![CDATA[我们在写文章的时候，难免会少不了添加一些链接。这些链接有的是指向自己的BLOG内的，有的是指向好友的BLOG，或一篇文章。指向自己BLOG的称为内部链接，指向外部的称为外部链接，我们习惯是外部链接在新窗口中打开，而内部链接在本身的页面打开。但WordPress默认所有的链接都是在自身页打开的。那要怎么才能把外部的链接强行在新窗口中打开呢？今天给大家说下怎样实现给文章的外部链接添加一个标识，并且在符合W3C标准的前提下在新窗口中打开。 而内部链接在本身页面打开。 我们知道，链接A的属性里有一个target=”_blank”。我们可以通过给链接添加这个属性来让链接在新窗口中打开。但这样为每个链接添加一个这样的属性并不是件轻松的事。而且还有个弊端：给A标签里面加target=”_blank”针对W3C标准是不合法的。那该如何解决呢？别急！跟着我来一步一步解决问题。 第一步：我们先要让文章里的链接全部在新窗口中打开： jQuery(.entry a).click(function(){window.open(this.href);return false;}); 第二步：给文章里的链接添加一个标识符 这个我们可以直接在CSS里定义 entry a {background:(images/out-links.gif) right top no-repeat; padding-right: 12px;} 现在文章里所有的链接都在新窗口中打开了，并且还带了一个标识的图标。但这并不是我们想要的，因为我们只想把标识符给外部链接并且内部链接是在自身窗口中打开的。继续下一步； 第三步：去掉内部链接的标识符 做这一步前我们首先要做的是区分文章里的链接是内部链接还是外部链接。这个可以用jQuery的选择器来区分，以我的BLOG为例：内部链接的href里肯定会包含我的域名（http://leotheme.cn）里的leotheme这个字符串。知道了这个我们就可以写代码了： jQuery(&#34;a[href*='leotheme']&#34;).css({background: &#34;none&#34;, padding: &#34;0&#34;}); 好了，现在内部链接没有标识符了，但还是会在新窗口中打开，继续。。。 第四步：让外部链接在新窗口中打开，内部链接在自身窗口打开 这一步的实现有一点点的复杂，当然如果你对jQuery非常熟悉的话还是非常简单的。前面我们在第一步已经实了文章所有链接在新窗口中打开了。但我们其实需要的只是外部链接在新窗口中打开而已，但外部链接的形式多样。变数太多，用JQ无法区别开来，但我们可以很容易区别内部链接，于是我们换下思路，“外部链接=除内部链接以外所有的链接”。在第一步的基础上我们只要排除了内部的链接就行了。但怎样排除呢。我们知道：HTML4.0增加了一个新属性：rel，这个属性用来说明链接和包含此链接页面的关系，以及链接打开的目标。我们可以给内部链接添天一个rel属性用来区分外部链接，然后用JQ的选择器排除内部链接。看下面的代码，我们在第三步的基础上修改下： jQuery(&#34;a[href*='leotheme']&#34;).css({background: &#34;none&#34;, padding: &#34;0&#34;}).attr(&#34;rel&#34;,&#34;inlinks&#34;); 现在所有的内部链接都有rel=”inlinks”这个属性了。接着我们用JQ来排除内部链接在新窗口中打开，排除的方法是，如果链接的rel不具有inlinks这个属性的话，那么它就是一个外部链接，然后我们给这个外部链接添加一个click事件，点击后在新窗口中打开。 jQuery(&#34;.entry a[rel!='inlinks']&#34;).click(function(){window.open(this.href);return false;}); NOW&#8230;现在文章的内部链接会在自身窗口中打开，而外部链接会在新窗口中打开并且还有个标识符了。效果见我的BLOG；写完了？好像是？效果也实现了？其实还没完，效果是实现了，但还有一些特殊的情况没有考滤进来。比如文章中的图片链接，锚链接&#8230;OK，继续排除这两个链接。 第五步：排除图片和锚链接 jQuery(&#34;.entry a:has(img)&#34;).css({background: &#34;none&#34;, padding: &#34;0&#34;}).attr(&#34;rel&#34;,&#34;inlinks&#34;);jQuery(&#34;.entry a[href*='#']&#34;).css({background: &#34;none&#34;, padding: &#34;0&#34;}).attr(&#34;rel&#34;,&#34;inlinks&#34;); 这下是真的完了。看起来好像写了很多代码，很复杂。其实很简单。我们把它优化下，写在一起。最后的完整代码是这样的： jQuery(&#34;.entry a[href*='http://leotheme'],.entry a:has(img),.entry a[href*=#]&#34;).css({background: &#34;none&#34;, padding: &#34;0&#34;}).attr(&#34;rel&#34;,&#34;inlinks&#34;);jQuery(&#34;.entry a[rel!='inlinks']&#34;).click(function(){window.open(this.href);return [...]]]></description>
			<content:encoded><![CDATA[<p>我们在写文章的时候，难免会少不了添加一些链接。这些链接有的是指向自己的BLOG内的，有的是指向好友的BLOG，或一篇文章。指向自己BLOG的称为内部链接，指向外部的称为外部链接，我们习惯是外部链接在新窗口中打开，而内部链接在本身的页面打开。但WordPress默认所有的链接都是在自身页打开的。那要怎么才能把外部的链接强行在新窗口中打开呢？今天给大家说下怎样实现给文章的外部链接添加一个标识，并且在符合<a href="http://www.w3.org/">W3C标准</a>的前提下在新窗口中打开。<br />
<span id="more-192"></span><br />
而内部链接在本身页面打开。</p>
<p>我们知道，链接A的属性里有一个target=”_blank”。我们可以通过给链接添加这个属性来让链接在新窗口中打开。但这样为每个链接添加一个这样的属性并不是件轻松的事。而且还有个弊端：给A标签里面加target=”_blank”针对<a href="http://www.w3.org/">W3C标准</a>是不合法的。那该如何解决呢？别急！跟着我来一步一步解决问题。</p>
<p><strong>第一步：我们先要让文章里的链接全部在新窗口中打开：</strong></p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: Gray;">.</span><span style="color: Blue;">entry</span><span style="color: Gray;"> </span><span style="color: Blue;">a</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Teal;">window</span><span style="color: Gray;">.</span><span style="color: Blue;">open</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">href</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;</span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div></div>
<p><strong>第二步：给文章里的链接添加一个标识符</strong><br />
这个我们可以直接在CSS里定义</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">entry</span><span style="color: Gray;"> </span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Green;">background:</span><span style="color: Gray;">(images/out-links.gif) </span><span style="color: Red;">right</span><span style="color: Gray;"> </span><span style="color: Red;">top</span><span style="color: Gray;"> </span><span style="color: Red;">no-repeat</span><span style="color: Green;"></span><span style="color: Gray;">; </span><span style="color: Green;">padding-right:</span><span style="color: Gray;"> </span><span style="color: Maroon;">12</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></div></div>
<p>现在文章里所有的链接都在新窗口中打开了，并且还带了一个标识的图标。但这并不是我们想要的，因为我们只想把标识符给外部链接并且内部链接是在自身窗口中打开的。继续下一步；</p>
<p><strong>第三步：去掉内部链接的标识符</strong></p>
<p>做这一步前我们首先要做的是区分文章里的链接是内部链接还是外部链接。这个可以用jQuery的选择器来区分，以我的BLOG为例：内部链接的href里肯定会包含我的域名（<a href="http://leotheme.cn/">http://leotheme.cn</a>）里的leotheme这个字符串。知道了这个我们就可以写代码了：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">a[href*='leotheme']</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">({</span><span style="color: Blue;">background</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">none</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">padding</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div></div>
<p>好了，现在内部链接没有标识符了，但还是会在新窗口中打开，继续。。。</p>
<p><strong>第四步：让外部链接在新窗口中打开，内部链接在自身窗口打开</strong></p>
<p>这一步的实现有一点点的复杂，当然如果你对<a href="http://jquery.com/">jQuery</a>非常熟悉的话还是非常简单的。前面我们在第一步已经实了文章所有链接在新窗口中打开了。但我们其实需要的只是外部链接在新窗口中打开而已，但外部链接的形式多样。变数太多，用JQ无法区别开来，但我们可以很容易区别内部链接，于是我们换下思路，“外部链接=除内部链接以外所有的链接”。在第一步的基础上我们只要排除了内部的链接就行了。但怎样排除呢。我们知道：HTML4.0增加了一个新属性：rel，这个属性用来说明链接和包含此链接页面的关系，以及链接打开的目标。我们可以给内部链接添天一个rel属性用来区分外部链接，然后用JQ的选择器排除内部链接。看下面的代码，我们在第三步的基础上修改下：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">a[href*='leotheme']</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">({</span><span style="color: Blue;">background</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">none</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">padding</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">})</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">rel</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">inlinks</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div></div>
<p>现在所有的内部链接都有rel=”inlinks”这个属性了。接着我们用JQ来排除内部链接在新窗口中打开，排除的方法是，如果链接的rel不具有inlinks这个属性的话，那么它就是一个外部链接，然后我们给这个外部链接添加一个click事件，点击后在新窗口中打开。</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.entry a[rel!='inlinks']</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Teal;">window</span><span style="color: Gray;">.</span><span style="color: Blue;">open</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">href</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;</span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div></div>
<p>NOW&#8230;现在文章的内部链接会在自身窗口中打开，而外部链接会在新窗口中打开并且还有个标识符了。效果见我的BLOG；写完了？好像是？效果也实现了？其实还没完，效果是实现了，但还有一些特殊的情况没有考滤进来。比如文章中的图片链接，锚链接&#8230;OK，继续排除这两个链接。</p>
<p><strong>第五步：排除图片和锚链接</strong></p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.entry a:has(img)</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">({</span><span style="color: Blue;">background</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">none</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">padding</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">})</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">rel</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">inlinks</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.entry a[href*='#']</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">({</span><span style="color: Blue;">background</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">none</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">padding</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">})</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">rel</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">inlinks</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div></div>
<p>这下是真的完了。看起来好像写了很多代码，很复杂。其实很简单。我们把它优化下，写在一起。最后的完整代码是这样的：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.entry a[href*='http://leotheme'],.entry a:has(img),.entry a[href*=#]</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">({</span><span style="color: Blue;">background</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">none</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">padding</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">})</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">rel</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">inlinks</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.entry a[rel!='inlinks']</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Teal;">window</span><span style="color: Gray;">.</span><span style="color: Blue;">open</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">href</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;</span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div></div>
<p>两行代码。对，就是这么简单。<a href="http://jquery.com/">jQuery</a>的选择器很强大&#8230;</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009-08-28 -- <a href="http://leotheme.cn/javascript/jquery-dragoninteractive-navi.html" title="jQuery实现背景图渐变切换">jQuery实现背景图渐变切换</a> (10)<br /><small>链接的背景图切换一般都用CSS的HOVER来控制，虽然很方便，但效果不怎么酷，没有平滑效果，显得有点突然。在这篇文章里给大家介绍下如何用jQuery来实现一个平滑的渐变式背景切换。效果大家可以看下这个...</small></li><li>2008-08-15 -- <a href="http://leotheme.cn/javascript/quediaolinksdesxk.html" title="去掉链接时虚线框的几个方法">去掉链接时虚线框的几个方法</a> (5)<br /><small>我想很多朋友都遇到这个问题，当点击一个链接的时候，总会出现一个虚线框。
在这介绍几种去除的方法：
1.直接给链接加是onfocus="this.blur()".
链接
2.CSS实现

...</small></li><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2011-09-08 -- <a href="http://leotheme.cn/javascript/jquery%e4%b8%adqueue%e5%92%8cdequeue%e7%9a%84%e7%94%a8%e6%b3%95.html" title="jQuery中queue和dequeue的用法">jQuery中queue和dequeue的用法</a> (1)<br /><small>今天在做右下角那个静止的工具栏时遇到了一个问题。鼠标放上去的时候，要让周围的4个按钮按顺序显示出来，移开的时候要按顺序隐藏。左思右想发现用animate的回调函数方式来写比较麻烦。于是百度了下，发现j...</small></li><li>2011-08-17 -- <a href="http://leotheme.cn/wordpress/flight-update.html" title="Flight主题更新">Flight主题更新</a> (16)<br /><small>这几天收到有些童鞋反应主题在wp3.2版本后台不能快速编缉文章，不能上传图片。抽空看了下，是JQ库版本冲突引起，现已更新。请移步到wopus主题站下载更新后的版本。也可以通过115网盘下载。...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/zq-ued-of-links.html/feed</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>按比例缩小图片方法总结</title>
		<link>http://leotheme.cn/javascript/reimgsize-zongjie.html</link>
		<comments>http://leotheme.cn/javascript/reimgsize-zongjie.html#comments</comments>
		<pubDate>Wed, 19 Nov 2008 03:49:26 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[缩小]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=178</guid>
		<description><![CDATA[其实早些时候就想写一下这个东东，因为想换下主题用用，但发现日志里的图片却因为太大而把POST撑开了，变得很难看。我想遇到这个问题的人一定不少吧。之前一直太忙，没时间去整它，今天抽点时间写一下怎样解决图片撑开的问题，方法很多的、接下来一一给大家道来&#8230; 方法一：Max-width&#124;Max-height 这是最简单的方法了，给图片一个最大的宽度和高度: #Imgbox img {&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; max-width: 500px;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; max-height: 300px;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; border:0;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; } 但它的效果并不怎么好，因为目前的IE6并不认识这个max-width和max-height。而且有时候图片的宽高相差很大。这样做后图片会变形。 方法二：Max-width/height+Expression 先来了解下什么是CSS expression： IE5及其以后版本支持在CSS中使用expression，用来把CSS属性和Javascript脚本关联起来，这里的CSS属性可以是元素固有的属性，也可以是自定义属性。就是说CSS属性后面可以是一段Javascript表达式，CSS属性的值等于Javascript表达式计算的结果。 在表达式中可以直接引用元素自身的属性和方法，也可以使用其他浏览器对象。这个表达式就好像是在这个元素的一个成员函数中一样。 了解了之后就简单了，其实就是把JS写到了CSS中，方便应用。我们来看下CSS怎么写: #Imgbox img {&#160;&#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>其实早些时候就想写一下这个东东，因为想换下主题用用，但发现日志里的图片却因为太大而把POST撑开了，变得很难看。我想遇到这个问题的人一定不少吧。之前一直太忙，没时间去整它，今天抽点时间写一下怎样解决图片撑开的问题，方法很多的、接下来一一给大家道来&#8230;</p>
<p><strong>方法一：Max-width|Max-height</strong><br />
这是最简单的方法了，给图片一个最大的宽度和高度:<br />
<span id="more-178"></span></p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">#Imgbox</span><span style="color: Gray;"> </span><span style="color: Blue;">img</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">max-width:</span><span style="color: Gray;"> </span><span style="color: Maroon;">500</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">max-height:</span><span style="color: Gray;"> </span><span style="color: Maroon;">300</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">border:</span><span style="color: Maroon;">0</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></div></div>
<p>但它的效果并不怎么好，因为目前的IE6并不认识这个max-width和max-height。而且有时候图片的宽高相差很大。这样做后图片会变形。</p>
<p><strong>方法二：Max-width/height+Expression</strong><br />
先来了解下什么是CSS expression：</p>
<blockquote><p>IE5及其以后版本支持在CSS中使用expression，用来把CSS属性和Javascript脚本关联起来，这里的CSS属性可以是元素固有的属性，也可以是自定义属性。就是说CSS属性后面可以是一段Javascript表达式，CSS属性的值等于Javascript表达式计算的结果。 在表达式中可以直接引用元素自身的属性和方法，也可以使用其他浏览器对象。这个表达式就好像是在这个元素的一个成员函数中一样。</p></blockquote>
<p>了解了之后就简单了，其实就是把JS写到了CSS中，方便应用。我们来看下CSS怎么写:</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">#Imgbox</span><span style="color: Gray;"> </span><span style="color: Blue;">img</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">max-width:</span><span style="color: Gray;"> </span><span style="color: Maroon;">500</span><span style="color: Red;">px</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">width:</span><span style="color: Gray;">expression(document.body.clientWidth &gt; </span><span style="color: Maroon;">500</span><span style="color: Gray;">?&quot;</span><span style="color: Maroon;">500</span><span style="color: Red;">px</span><span style="color: Gray;">&quot;:&quot;</span><span style="color: Red;">auto</span><span style="color: Gray;">&quot; )</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">display:</span><span style="color: Red;">block</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">border:</span><span style="color: Maroon;">0</span><span style="color: Green;"></span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></div></div>
<p>这样做虽然实现了等比例缩放，但它还是有它的缺点：会影响浏览器的速度，因为Expression是很占资源的一个东东，所以，一般不是没办法了不建议用CSS的Expression。难道没有好的解决方法了？不，当然有，接着往下看。</p>
<p><strong>方法三：JavaScript实现</strong><br />
应该是这是现在最好的解决方法了，我们看下代码：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">ReImgSize</span><span style="color: Olive;">(){</span><span style="color: Gray;"> <br /></span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">await</span><span style="color: Gray;"> = </span><span style="color: Teal;">document</span><span style="color: Gray;">.</span><span style="color: Blue;">getElementById</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Imgbox</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: #ffa500;">//定义要改变的图片的容器ID</span><span style="color: Gray;"><br /></span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">imgall</span><span style="color: Gray;"> = </span><span style="color: Blue;">await</span><span style="color: Gray;">.</span><span style="color: Blue;">getElementsByTagName</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">img</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span><span style="color: #ffa500;">//取得容器内所有的IMG标签</span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Green;">for</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Gray;">=</span><span style="color: Maroon;">0</span><span style="color: Gray;">;</span><span style="color: Blue;">i</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">imgall</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;">;</span><span style="color: Blue;">i</span><span style="color: Gray;">++</span><span style="color: Olive;">)</span><span style="color: Gray;"> <br />&nbsp;&nbsp; </span><span style="color: Olive;">{</span><span style="color: Gray;"> <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">imgall</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Gray;">&gt;</span><span style="color: Maroon;">500</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: #ffa500;">//如果图片的宽度大于500</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; </span><span style="color: Olive;">{</span><span style="color: Gray;"> <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">oWidth</span><span style="color: Gray;">=</span><span style="color: Blue;">imgall</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Gray;">; </span><span style="color: #ffa500;">//取得图片的实际宽度</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">oHeight</span><span style="color: Gray;">=</span><span style="color: Blue;">imgall</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Gray;">; </span><span style="color: #ffa500;">//取得图片的实际高度</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">imgall</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">500</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">; 重设图片的宽度为</span><span style="color: Maroon;">500</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">imgall</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Gray;">=</span><span style="color: Blue;">oHeight</span><span style="color: Gray;">*</span><span style="color: Maroon;">500</span><span style="color: #8b0000;">/</span><span style="color: Red;">oWidth; </span><span style="color: #8b0000;">//</span><span style="color: Red;">重设图片的高度<br />&nbsp;&nbsp; &nbsp; &nbsp; } <br />&nbsp;&nbsp; &nbsp;} <br />}</span></div></div>
<p>用法：把上面代码放到Head区，然后在Body标签中加入onload=”ReImgSize”;</p>
<p>最后给大家介绍一个jQuery的插件，用来改变图片的大小，而且还能实现图片的预加载。这个插件很小不到2KB。</p>
<p>它有4个参数：<br />
scaling     是否等比例自动缩放<br />
width       图片最大高<br />
height      图片最大宽<br />
loadpic     加载中的图片路径</p>
<p>实际应用中我们先把JS加载进来然后用一句代码就能实现了</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">img</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">LoadImage</span><span style="color: Olive;">(</span><span style="color: Green;">true</span><span style="color: Gray;">,</span><span style="color: Maroon;">500</span><span style="color: Gray;">,</span><span style="color: Maroon;">200</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">loading.gif</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div></div>
<p>效果不错的。喜欢试下的可以在下面的链接下载<a href="http://leotheme.cn/wp-content/uploads/2008/11/jqueryloadimagedemo.rar">DEMO</a>。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2008-09-09 -- <a href="http://leotheme.cn/javascript/donotcssexpression.html" title="为什么尽量不要使用CSS Expression">为什么尽量不要使用CSS Expression</a> (0)<br /><small>CSS Expression也称为CSS表达式，它是动态设置CSS属性的强大方法，但也存在着一定的危险性。

在CSS Expression中使用JavaScript表达式。CSS属性根据Java...</small></li><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/reimgsize-zongjie.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CSS中关于背景图的应用技巧</title>
		<link>http://leotheme.cn/javascript/about-css-background.html</link>
		<comments>http://leotheme.cn/javascript/about-css-background.html#comments</comments>
		<pubDate>Sat, 08 Nov 2008 22:38:29 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[背景]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=146</guid>
		<description><![CDATA[在CSS中对背景图的作法.一般都是这样: background: url(images/*.gif) no-repeat; 但有时候有很多图片的时候,像我的Maxthon主题,就用了很多的背景图和图标.这时候如果还这样做的话就会带来一个问题,图片在加载中会有个过程.虽然很快.但有的图片在一开始并没有加载进来,而是在响应鼠标事件时才开始加载.像我的导航栏。默认是一个背景，鼠标放上去是一个背景，当前页又是另一个背景。 这时如果还像普通的处理的话,当鼠标放上去后,并不能马上看到图片.所以在Maxthon 2.0中我已经不用以前的方法来做了.而是选择把所有的背景图片放到一张图上.就像下面这样. 放到一起后，当鼠标放上去后而不用向服务器请求,因为图片已经在第一次就已加载完成，不会产生延迟的效果.这样做还有个好处，就是可以减少向服务器请求的次数，从而使加载更快。 现在来说说放到一张图上后，CSS中该怎么定义? 以我的导航栏为例: 假如我们在做图的时候,图片的上面是默认时的背片,中间是鼠标放去时的.下面是当前页码的.图片的高度是30PX;那么这张图的总高度是90PX; 然后我们在CSS中这样写: [sourcecode lang="css"]#nav li a {background: url(images/bg_nav.gif) 0 0 repeat-x;}默认时的 #nav li a:hover {background: url(images/bg_nav.gif) 0 -30px repeat-x;}鼠标放上去时的 #nav li a .current {background: url(images/bg_nav.gif) 0 -60px repeat-x;}当前页效果的[/sourcecode] 我们在CSS中定义的背景图都是同一张,我们通过改变他的Y座标起始位置来定位.因为我们的高度已经是固定了的30PX,和图片的高度是一样的.然后让它沿X坐标平铺.这样就达到我们要的效果了. 相关文章2011-09-24 -- 使用lesscss来编码编写css (10)lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。 lesscss使用方法有两种： 页面添加一个 less.js的文...2009-11-11 -- 左右两栏等高实现方法 (6)等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...2009-08-30 -- CSS 3.0 参考手册 (中文版) [...]]]></description>
			<content:encoded><![CDATA[<p>在CSS中对背景图的作法.一般都是这样:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">background: url(images/*.gif) no-repeat;</li></ol></div>
<p>但有时候有很多图片的时候,像我的Maxthon主题,就用了很多的背景图和图标.这时候如果还这样做的话就会带来一个问题,图片在加载中会有个过程.虽然很快.但有的图片在一开始并没有加载进来,而是在响应鼠标事件时才开始加载.像我的导航栏。默认是一个背景，鼠标放上去是一个背景，当前页又是另一个背景。<br />
<span id="more-146"></span><br />
这时如果还像普通的处理的话,当鼠标放上去后,并不能马上看到图片.所以在Maxthon 2.0中我已经不用以前的方法来做了.而是选择把所有的背景图片放到一张图上.就像下面这样.</p>
<p><img src="http://leotheme.cn/wp-content/uploads/2008/11/icon.jpg" alt="icon" title="icon" width="150" height="271" class="alignnone size-full wp-image-147" /></p>
<p>放到一起后，当鼠标放上去后而不用向服务器请求,因为图片已经在第一次就已加载完成，不会产生延迟的效果.这样做还有个好处，就是可以减少向服务器请求的次数，从而使加载更快。</p>
<p>现在来说说放到一张图上后，CSS中该怎么定义?</p>
<p>以我的导航栏为例:<br />
假如我们在做图的时候,图片的上面是默认时的背片,中间是鼠标放去时的.下面是当前页码的.图片的高度是30PX;那么这张图的总高度是90PX;<br />
然后我们在CSS中这样写:</p>
<p>[sourcecode lang="css"]#nav li a {background: url(images/bg_nav.gif) 0 0 repeat-x;}默认时的<br />
#nav li a:hover {background: url(images/bg_nav.gif) 0 -30px repeat-x;}鼠标放上去时的<br />
#nav li a .current {background: url(images/bg_nav.gif) 0 -60px repeat-x;}当前页效果的[/sourcecode]</p>
<p>我们在CSS中定义的背景图都是同一张,我们通过改变他的Y座标起始位置来定位.因为我们的高度已经是固定了的30PX,和图片的高度是一样的.然后让它沿X坐标平铺.这样就达到我们要的效果了.</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (10)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-08-28 -- <a href="http://leotheme.cn/javascript/jquery-dragoninteractive-navi.html" title="jQuery实现背景图渐变切换">jQuery实现背景图渐变切换</a> (10)<br /><small>链接的背景图切换一般都用CSS的HOVER来控制，虽然很方便，但效果不怎么酷，没有平滑效果，显得有点突然。在这篇文章里给大家介绍下如何用jQuery来实现一个平滑的渐变式背景切换。效果大家可以看下这个...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/about-css-background.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

