<?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>SunLe&#039;Blog---孙乐 &#187; css</title>
	<atom:link href="http://www.sunle.net/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sunle.net</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 02:04:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>通过CSS让WordPress图片成比例自动缩小</title>
		<link>http://www.sunle.net/css-wordpress-tupian-suoxiao.html</link>
		<comments>http://www.sunle.net/css-wordpress-tupian-suoxiao.html#comments</comments>
		<pubDate>Sat, 08 May 2010 15:23:29 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[自动缩小]]></category>

		<guid isPermaLink="false">http://www.sunle.net/?p=1132</guid>
		<description><![CDATA[不知道大家发现没有，有时候贴入WordPress的图片尺寸过大，结果导致文章发布后图片撑破页面。整个版式变的一团糟。如果我们要贴入WordPress的大尺寸图片很多，一张一张的去调整尺寸会很麻烦，有没有简单实用的办法（如通过CSS定义）让WordPress把图片自动成比例缩小到一定程度呢？通过GG还真找到相关的方法。 经过实验，发现只要在主题的CSS上加上几句代码即可。 max-width:600px; width: expression(this.width &#62; 600 ? &#34;600px&#34; : true); height:auto; 这样就可以实现自动按宽高比缩小了。 网上还介绍了一种用jQuery实现的方法，似乎更智能，我觉得可以配合lightbox使用，效果更佳。 方法： 加载jQuery库 将以下代码加入header.php或单独保存为JS并加载 $(document).ready(function(){ &#160;&#160; &#160;$('div').autoResize({height:750}); });&#160; &#160;jQuery.fn.autoResize = function(options) { &#160;&#160; &#160;var opts = { &#160;&#160; &#160; &#160; &#160;'width' : 700, &#160;&#160; &#160; &#160; &#160;'height': 750 &#160;&#160; &#160;} &#160;&#160; &#160;var opt = $.extend(true, {},opts,options &#124;&#124; {}); &#160;&#160; &#160;width = opt.width; [...]]]></description>
			<content:encoded><![CDATA[<p>不知道大家发现没有，有时候贴入WordPress的图片尺寸过大，结果导致文章发布后图片撑破页面。整个版式变的一团糟。如果我们要贴入WordPress的大尺寸图片很多，一张一张的去调整尺寸会很麻烦，有没有简单实用的办法（如通过CSS定义）让WordPress把图片自动成比例缩小到一定程度呢？通过GG还真找到相关的方法。<br />
<span id="more-1132"></span><br />
经过实验，发现只要在主题的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">max-width:600px;</li>
<li>width: expression(this.width &gt; 600 ? &quot;600px&quot; : true);</li>
<li>height:auto;</li></ol></div>
<p>这样就可以实现自动按宽高比缩小了。</p>
<p>网上还介绍了一种用jQuery实现的方法，似乎更智能，我觉得可以配合lightbox使用，效果更佳。 </p>
<p>方法：</p>
<p>加载jQuery库<br />
将以下代码加入header.php或单独保存为JS并加载 </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">$(document).ready(function(){</li>
<li>&nbsp;&nbsp; &nbsp;$('div').autoResize({height:750});</li>
<li>});&nbsp; &nbsp;jQuery.fn.autoResize = function(options)</li>
<li>{</li>
<li>&nbsp;&nbsp; &nbsp;var opts = {</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;'width' : 700,</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;'height': 750</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;var opt = $.extend(true, {},opts,options || {});</li>
<li>&nbsp;&nbsp; &nbsp;width = opt.width;</li>
<li>&nbsp;&nbsp; &nbsp;height = opt.height;</li>
<li>&nbsp;&nbsp; &nbsp;$('img',this).each(function(){</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var image = new Image();</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;image.src = $(this).attr('src');&nbsp; &nbsp;if(image.width &gt; 0 &amp;&amp; image.height &gt; 0 ){</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var image_rate = 1;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if( (width / image.width) &lt; (height / image.height)){</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;image_rate = width / image.width ;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}else{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;image_rate = height / image.height ;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( image_rate &lt;= 1){</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$(this).width(image.width * image_rate);</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$(this).height(image.height * image_rate);</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;});</li>
<li>}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/css-wordpress-tupian-suoxiao.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>css中IE下判断IE版本的语句</title>
		<link>http://www.sunle.net/css-judge-ie-version-code.html</link>
		<comments>http://www.sunle.net/css-judge-ie-version-code.html#comments</comments>
		<pubDate>Wed, 17 Jun 2009 08:25:24 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[判断]]></category>
		<category><![CDATA[版本]]></category>
		<category><![CDATA[语句]]></category>

		<guid isPermaLink="false">http://www.sunle.net/?p=931</guid>
		<description><![CDATA[<p>1.
<p>++CoolCode_BLOCK_5++</p>
<p>2.
<p>++CoolCode_BLOCK_6++</p>
<p>3.
<p>++CoolCode_BLOCK_7++</p>
<p>4.
<p>++CoolCode_BLOCK_8++</p>
<p>5.
<p>++CoolCode_BLOCK_9++</p>
<p>6.
<p>++CoolCode_BLOCK_10++</p>
<p>7.
<p>++CoolCode_BLOCK_11++</p>
<p>8.
<p>++CoolCode_BLOCK_12++</p>
<p>9.
<p>++CoolCode_BLOCK...</p><p><a href='http://www.sunle.net/css-judge-ie-version-code.html' rel="nofollow">点击阅读全文</a></p>]]></description>
			<content:encoded><![CDATA[<p>1.
<p>++CoolCode_BLOCK_23++</p>
<p>2.
<p>++CoolCode_BLOCK_24++</p>
<p>3.
<p>++CoolCode_BLOCK_25++</p>
<p>4.
<p>++CoolCode_BLOCK_26++</p>
<p>5.
<p>++CoolCode_BLOCK_27++</p>
<p>6.
<p>++CoolCode_BLOCK_28++</p>
<p>7.
<p>++CoolCode_BLOCK_29++</p>
<p>8.
<p>++CoolCode_BLOCK_30++</p>
<p>9.
<p>++CoolCode_...</p><p><a href='http://www.sunle.net/css-judge-ie-version-code.html' rel="nofollow">点击阅读全文</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/css-judge-ie-version-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最新CSS兼容方案</title>
		<link>http://www.sunle.net/news-css-kack-20090613.html</link>
		<comments>http://www.sunle.net/news-css-kack-20090613.html#comments</comments>
		<pubDate>Sat, 13 Jun 2009 03:44:46 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[兼容]]></category>
		<category><![CDATA[方案]]></category>

		<guid isPermaLink="false">http://www.sunle.net/?p=911</guid>
		<description><![CDATA[HACK1： #example { margin:5px!important; /* for Firefox */ margin:10px; /* for IE6 */ margin /**/:11px; /* for IE5 */ } *+html #example{margin:15px!important; }/* for IE7 */ 说明：!important声明可以提升指定样式规则的应用优先权。上面“for Firefox” 有“!important”，“for IE7” 也要加“!important”，否则实际出来后IE7依然使用第一个maring值5px。 HACK2： #example {margin:5px; }/* for Firefox */ * html #example {margin:10px;} /* for IE6 */ *+html #abc{margin:15px!important;} /* for IE7 */ 说明：“for IE7”要加“!important”，“+html”能被ie7与ie5.01所识别，但ie5.01不识别important，所以*+html 再加!important [...]]]></description>
			<content:encoded><![CDATA[<p>HACK1： </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">#example {</li>
<li>margin:5px!important; /* for Firefox */</li>
<li>margin:10px; /* for IE6 */</li>
<li>margin /**/:11px; /* for IE5 */</li>
<li>}</li>
<li>*+html #example{margin:15px!important; }/* for IE7 */</li></ol></div>
<p><span id="more-911"></span><br />
说明：!important声明可以提升指定样式规则的应用优先权。上面“for Firefox” 有“!important”，“for IE7” 也要加“!important”，否则实际出来后IE7依然使用第一个maring值5px。<br />
HACK2： </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">#example {margin:5px; }/* for Firefox */</li>
<li>* html #example {margin:10px;} /* for IE6 */</li>
<li>*+html #abc{margin:15px!important;} /* for IE7 */</li></ol></div>
<p>说明：“for IE7”要加“!important”，“+html”能被ie7与ie5.01所识别，但ie5.01不识别important，所以*+html 再加!important 才只能被ie7识别。<br />
HACK3： </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">#example {</li>
<li>margin:5px; /* For Firefox */</li>
<li>*margin:10px; /* For IE7 &amp; IE6*/</li>
<li>_margin:15px; /* For IE6*/</li>
<li>}</li></ol></div>
<p>说明：这样写CSS文件无法通过验证，但是代码可以写的比较少。<br />
HACK4：使用IE专用的条件注释 <!--其他浏览器 --></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">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css.css&quot; /&gt;</li>
<li>&lt;!--[if IE 7]&gt;</li>
<li>&lt;!-- 适合于IE7 --&gt;</li>
<li>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie7.css&quot; /&gt;</li>
<li>&lt;![endif]--&gt;</li>
<li>&lt;!--[if lte IE 6]&gt;</li>
<li>&lt;!-- 适合于IE6及以下 --&gt;</li>
<li>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie.css&quot; /&gt;</li>
<li>&lt;![endif]--&gt;</li></ol></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">[*]gt /Greater than/大于/&lt;!--[if gt IE 5.5]&gt; </li>
<li>[*]gte /Greater than or equal to/大于等于/&lt;!--[if gte IE 5.5]&gt; </li>
<li>[*]lt /Less than/小于/&lt;!--[if lt IE 5.5]&gt; </li>
<li>[*]lte /Less than or equal to/小于等于/&lt;!--[if lte IE 5.5]&gt; </li>
<li>[*]! /Note/不等于/&lt;!--[if !IE 5.5]&gt;</li></ol></div>
<p>HACK5： </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">example{</li>
<li>margin: 5px;/*FF*/</li>
<li>&gt;margin: 10px;/*IE5*/</li>
<li>}</li>
<li>example/*IE5.5 */{</li>
<li>&gt;/*IE only*/margin: 15px;/*IE6*/</li>
<li>&gt;/*IE only*/margin /*IE5.5*/: 20px;</li>
<li>}</li></ol></div>
<p>说明：“margin”定义的顺利不能改变，即FF-IE5-IE6-IE5.5。对于IE的定义在属性前要加“>”，因为“example/**/{}”这个HACK在FF中可以识别。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/news-css-kack-20090613.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>表单栏目提示效果</title>
		<link>http://www.sunle.net/form-fieldhints.html</link>
		<comments>http://www.sunle.net/form-fieldhints.html#comments</comments>
		<pubDate>Sun, 21 Dec 2008 14:59:59 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[提示]]></category>
		<category><![CDATA[表格]]></category>

		<guid isPermaLink="false">http://www.sunle.net/?p=578</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;title&#62;Form field hints with CSS and JavaScript&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; /* All form elements are within the definition list for this example */ dl { font:normal 12px/15px Arial; position: relative; width: 350px; } dt { clear: both; float:left; width: 130px; padding: 4px 0 2px 0; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sunle.net/wp-content/uploads/2008/12/111.gif" rel="lightbox"><img src="http://www.sunle.net/wp-content/uploads/2008/12/111-300x49.gif" alt="表单栏目提示效果" title="表单栏目提示效果" width="300" height="49" class="aligncenter size-medium wp-image-579" /></a></p>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_LEzlNB">&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;title&gt;Form field hints with CSS and JavaScript&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
/* All form elements are within the definition list for this example */
dl {
	font:normal 12px/15px Arial;
    position: relative;
    width: 350px;
}
dt {
    clear: both;
    float:left;
    width: 130px;
    padding: 4px 0 2px 0;
    text-align: left;
}
dd {
    float: left;
    width: 200px;
    margin: 0 0 8px 0;
    padding-left: 6px;
}
/* The hint to Hide and Show */
.hint {
   	display: none;
    position: absolute;
    right: -250px;
    width: 200px;
    margin-top: -4px;
    border: 1px solid #c93;
    padding: 10px 12px;
    /* to fix IE6, I can't just declare a background-color,
    I must do a bg image, too!  So I'm duplicating the pointer.gif
    image, and positioning it so that it doesn't show up
    within the box */
    background: #ffc url(&quot;http://www.cssrain.cn/demo/formfieldhints/pointer.gif&quot;) no-repeat -10px 5px;
}
/* The pointer image is hadded by using another span */
.hint .hint-pointer {
    position: absolute;
    left: -10px;
    top: 5px;
    width: 10px;
    height: 19px;
    background: url(&quot;http://www.cssrain.cn/demo/formfieldhints/pointer.gif&quot;) left top no-repeat;
}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function prepareInputsForHints() {
	var inputs = document.getElementsByTagName(&quot;input&quot;);
	for (var i=0; i&lt;inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName(&quot;span&quot;)[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName(&quot;span&quot;)[0].style.display = &quot;inline&quot;;
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName(&quot;span&quot;)[0].style.display = &quot;none&quot;;
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName(&quot;select&quot;);
	for (var k=0; k&lt;selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName(&quot;span&quot;)[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName(&quot;span&quot;)[0].style.display = &quot;inline&quot;;
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName(&quot;span&quot;)[0].style.display = &quot;none&quot;;
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p style=&quot;font:normal 12px/15px Arial;&quot;&gt;Tab or click through the fields to reveal the hints.&lt;/p&gt;
&lt;dl&gt;
	&lt;dt&gt;
		&lt;label for=&quot;firstname&quot;&gt;First Name:&lt;/label&gt;
	&lt;/dt&gt;
	&lt;dd&gt;
		&lt;input
			name=&quot;firstname&quot;
			id=&quot;firstname&quot;
			type=&quot;text&quot; /&gt;
		&lt;span class=&quot;hint&quot;&gt;This is the name your mama called you when you were little.&lt;span class=&quot;hint-pointer&quot;&gt; &lt;/span&gt;&lt;/span&gt;
	&lt;/dd&gt;
	&lt;dt&gt;
		&lt;label for=&quot;lastname&quot;&gt;Last Name:&lt;/label&gt;
	&lt;/dt&gt;
	&lt;dd&gt;
		&lt;input
			name=&quot;lastname&quot;
			id=&quot;lastname&quot;
			type=&quot;text&quot; /&gt;
		&lt;span class=&quot;hint&quot;&gt;This is the name your sergeant called you when you went through bootcamp.&lt;span class=&quot;hint-pointer&quot;&gt; &lt;/span&gt;&lt;/span&gt;
	&lt;/dd&gt;
	&lt;dt&gt;
		&lt;label for=&quot;email&quot;&gt;Email:&lt;/label&gt;
	&lt;/dt&gt;
	&lt;dd&gt;
		&lt;input
			name=&quot;email&quot;
			id=&quot;email&quot;
			type=&quot;text&quot; /&gt;
		&lt;span class=&quot;hint&quot;&gt;The thing with the @ symbol and the dot com at the end.&lt;span class=&quot;hint-pointer&quot;&gt; &lt;/span&gt;&lt;/span&gt;
	&lt;/dd&gt;
	&lt;dt&gt;&lt;label for=&quot;year&quot;&gt;Birth Year:&lt;/label&gt;&lt;/dt&gt;
	&lt;dd&gt;
		&lt;select id=&quot;year&quot; name=&quot;year&quot;&gt;
			&lt;option value=&quot;&quot;&gt;YYYY&lt;/option&gt;
			&lt;option value=&quot;1066&quot;&gt;1066&lt;/option&gt;
			&lt;option value=&quot;1492&quot;&gt;1492&lt;/option&gt;
			&lt;option value=&quot;1776&quot;&gt;1776&lt;/option&gt;
			&lt;option value=&quot;1812&quot;&gt;1812&lt;/option&gt;
			&lt;option value=&quot;1917&quot;&gt;1917&lt;/option&gt;
			&lt;option value=&quot;1942&quot;&gt;1942&lt;/option&gt;
			&lt;option value=&quot;1999&quot;&gt;1999&lt;/option&gt;
		&lt;/select&gt;
		&lt;span class=&quot;hint&quot;&gt;Pick a famous year to be born in.&lt;span class=&quot;hint-pointer&quot;&gt; &lt;/span&gt;&lt;/span&gt;
	&lt;/dd&gt;
	&lt;dt&gt;
		&lt;label for=&quot;username&quot;&gt;Username:&lt;/label&gt;
	&lt;/dt&gt;
	&lt;dd&gt;
		&lt;input
			name=&quot;username&quot;
			id=&quot;username&quot;
			type=&quot;text&quot; /&gt;
		&lt;span class=&quot;hint&quot;&gt;Between 4-12 characters.&lt;span class=&quot;hint-pointer&quot;&gt; &lt;/span&gt;&lt;/span&gt;
	&lt;/dd&gt;
	&lt;dt&gt;
		&lt;label for=&quot;password&quot;&gt;Password:&lt;/label&gt;
	&lt;/dt&gt;
	&lt;dd&gt;
		&lt;input
			name=&quot;password&quot;
			id=&quot;password&quot;
			type=&quot;password&quot; /&gt;
		&lt;span class=&quot;hint&quot;&gt;Between 5-13 characters, but not 7.  Never 7.&lt;span class=&quot;hint-pointer&quot;&gt; &lt;/span&gt;&lt;/span&gt;
	&lt;/dd&gt;
	&lt;dt class=&quot;button&quot;&gt; &lt;/dt&gt;
	&lt;dd class=&quot;button&quot;&gt;
		&lt;input
			type=&quot;submit&quot;
			class=&quot;button&quot;
			value=&quot;Submit&quot; /&gt;
	&lt;/dd&gt;
&lt;/dl&gt;
&lt;/body&gt;
&lt;/html&gt;</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_LEzlNB');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_LEzlNB');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>代码如下：<span id="more-578"></span></p>
<pre name="code" class="html:collapse">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">

/* All form elements are within the definition list for this example */
dl {
	font:normal 12px/15px Arial;
    position: relative;
    width: 350px;
}
dt {
    clear: both;
    float:left;
    width: 130px;
    padding: 4px 0 2px 0;
    text-align: left;
}
dd {
    float: left;
    width: 200px;
    margin: 0 0 8px 0;
    padding-left: 6px;
}

/* The hint to Hide and Show */
.hint {
   	display: none;
    position: absolute;
    right: -250px;
    width: 200px;
    margin-top: -4px;
    border: 1px solid #c93;
    padding: 10px 12px;
    /* to fix IE6, I can't just declare a background-color,
    I must do a bg image, too!  So I'm duplicating the pointer.gif
    image, and positioning it so that it doesn't show up
    within the box */
    background: #ffc url("http://www.cssrain.cn/demo/formfieldhints/pointer.gif") no-repeat -10px 5px;
}

/* The pointer image is hadded by using another span */
.hint .hint-pointer {
    position: absolute;
    left: -10px;
    top: 5px;
    width: 10px;
    height: 19px;
    background: url("http://www.cssrain.cn/demo/formfieldhints/pointer.gif") left top no-repeat;
}
</style>

<script type="text/javascript">
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i
<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);
</script>
</head>
<body>
<p style="font:normal 12px/15px Arial;">Tab or click through the fields to reveal the hints.
<dl>
<dt>
		<label for="firstname">First Name:</label>
	</dt>
<dd>
<input
			name="firstname"
			id="firstname"
			type="text" />
		<span class="hint">This is the name your mama called you when you were little.<span class="hint-pointer"> </span></span>
	</dd>
<dt>
		<label for="lastname">Last Name:</label>
	</dt>
<dd>
<input
			name="lastname"
			id="lastname"
			type="text" />
		<span class="hint">This is the name your sergeant called you when you went through bootcamp.<span class="hint-pointer"> </span></span>
	</dd>
<dt>
		<label for="email">Email:</label>
	</dt>
<dd>
<input
			name="email"
			id="email"
			type="text" />
		<span class="hint">The thing with the @ symbol and the dot com at the end.<span class="hint-pointer"> </span></span>
	</dd>
<dt><label for="year">Birth Year:</label></dt>
<dd>
<select id="year" name="year">
<option value="">YYYY</option>
<option value="1066">1066</option>
<option value="1492">1492</option>
<option value="1776">1776</option>
<option value="1812">1812</option>
<option value="1917">1917</option>
<option value="1942">1942</option>
<option value="1999">1999</option>
</select>

		<span class="hint">Pick a famous year to be born in.<span class="hint-pointer"> </span></span>
	</dd>
<dt>
		<label for="username">Username:</label>
	</dt>
<dd>
<input
			name="username"
			id="username"
			type="text" />
		<span class="hint">Between 4-12 characters.<span class="hint-pointer"> </span></span>
	</dd>
<dt>
		<label for="password">Password:</label>
	</dt>
<dd>
<input
			name="password"
			id="password"
			type="password" />
		<span class="hint">Between 5-13 characters, but not 7.  Never 7.<span class="hint-pointer"> </span></span>
	</dd>
<dt class="button"> </dt>
<dd class="button">
<input
			type="submit"
			class="button"
			value="Submit" />
	</dd>
</dl>

</body>
</html>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/form-fieldhints.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>firefox,ie7,ie6兼容性问题，和css解决方案</title>
		<link>http://www.sunle.net/firefox-ie7-ie6-jianrongjiejuefangfa.html</link>
		<comments>http://www.sunle.net/firefox-ie7-ie6-jianrongjiejuefangfa.html#comments</comments>
		<pubDate>Thu, 18 Dec 2008 14:57:04 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[ie7]]></category>

		<guid isPermaLink="false">http://www.sunle.net/?p=548</guid>
		<description><![CDATA[相信很多人听说过Hack，就是在CSS代码里加入一些如* html,+hmtl, /**/，这些代码在IE里能被识别，其它浏览器不能，也有些IE6可以，IE7不能识别，就是通过这样的方法，来写针对不同浏览器的CSS代码。 这里有几篇文章是介绍Hack的，还有收集了目前的一些Hack，可以点过去看看。先别急着点，继续往下看吧。最后我才把链接贴上，因为下面的内容更重要。比你漫无目的找HACK实用。 这里介绍几个经典的区别不同浏览器，CSS hack写法太多了，也很杂，这里我就介绍几款实用的，又容易记的写法： &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;经典方案一&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 注：IE都能识别*;标准浏览器(如Firefox,Opera,Netscape)不能识别*；IE6能识别*，但不能识别 !important,IE7能识别*，也能识别!important;FF不能识别*，但能识别!important;&#160;&#160; &#160; 写两句代码来控制一个属性，区别Firefox与IE6：&#160;&#160; background:orange;*background:blue;&#160;&#160; &#160; //这一句代码写出来时，你用firefox或其它非IE浏览时，会发现，写了该代码的区域背景是橙色的，如果用IE浏览，却是蓝色的，这是因为IE都能识别*;标准浏览器(如Firefox,Opera,Netscape)不能识别*；&#160;&#160; &#160; &#160; 写两句代码来控制一个属性，区别IE7与IE6：&#160;&#160; background:green !important;background:blue;&#160;&#160; &#160; //这一句代码写出来时，你用IE7浏览，会发现，写了该代码的区域背景是绿色的，如果用IE6浏览，却是蓝色的，这是因为IE7能识别!important*，一但识别了，就执行，忽略了后面的那一句，但IE6却不能识别!important，所以前面部分跳过，直接执行了后半部份。&#160;&#160; &#160; &#160; 写两句代码来控制一个属性，区别Firefox与IE：&#160;&#160; background:orange; *background:green;&#160;&#160; &#160; //这一句代码写出来时，你用Firefox浏览，会发现背景是橙色的，而IE里却是绿色的，很简单，因为Firefox不能识别*，而IE6，IE7都可以识*&#160;&#160; &#160; &#160; 写三句代码来控制一个属性，区别Firefox，IE7，IE6：&#160;&#160; background:orange;*background:green !important;*background:blue;&#160;&#160; &#160; //这一句会使在Firefox在，背景呈橙色，IE7中为绿色，IE6中为蓝色，道理和前面一样，Firefox不能识别*，所以后面两句都不执行，直接执行第一句，IE7当然也能执行第一行代码，但是因为第二句，他也能识别，所以就执行了第二句代码，把前面的效果给过滤了，而最后一句，IE7是不能识别的。IE6不能识别!imprtant，本来运行了第一句代码了，第二句不能识别，那就理所当然的执行了最后一句。&#160;&#160; &#160; 以上HACK用法，可以实现不同浏览器的CSS代码，但是却不能通过CSS代码验证工具的验证！其实通不通过都无所谓，主要是实用，至少我是这样认为。如果你想要写能通过验证的HACK。那么请继续往下看第二种方案。 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;经典方案二&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 下面介绍用* html,* +html的hack写法，此方法可以通过CSS验证，也比较规范。哈哈，HACK本来是不归范的产物，只是我个人认为这种Hack写法是Hack写法中的规范而已，不要拿东西砸我！！！&#160;&#160; &#160; 我写一个例子&#160;&#160; &#160; #sample&#160;{background:red;}&#160;&#160; &#160; *&#160;html #sample {backgroud:green;}&#160;&#160; &#160; * +html&#160;#sample{backgroud:blue}&#160;&#160; &#160; 在DW中建立一个sample层，写入以上代码，运行一下看看，你会在Firefox或是Netscape或Opera中看到，sample的背景色是红色的。在IE6中看到背景色是绿色的，而在IE7中却是蓝色的。好玩吧~&#160;&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>相信很多人听说过Hack，就是在CSS代码里加入一些如* html,+hmtl, /**/，这些代码在IE里能被识别，其它浏览器不能，也有些IE6可以，IE7不能识别，就是通过这样的方法，来写针对不同浏览器的CSS代码。</p>
<p>这里有几篇文章是介绍Hack的，还有收集了目前的一些Hack，可以点过去看看。先别急着点，继续往下看吧。最后我才把链接贴上，因为下面的内容更重要。比你漫无目的找HACK实用。</p>
<p>这里介绍几个经典的区别不同浏览器，CSS hack写法太多了，也很杂，这里我就介绍几款实用的，又容易记的写法：<br />
<span id="more-548"></span><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;经典方案一&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</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;">IE</span><span style="color: Gray;">都能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">;标准浏览器(如</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">,</span><span style="color: Blue;">Opera</span><span style="color: Gray;">,</span><span style="color: Blue;">Netscape</span><span style="color: Gray;">)不能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">；</span><span style="color: Blue;">IE6</span><span style="color: Gray;">能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">，但不能识别 !</span><span style="color: Blue;">important</span><span style="color: Gray;">,</span><span style="color: Blue;">IE7</span><span style="color: Gray;">能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">，也能识别!</span><span style="color: Blue;">important</span><span style="color: Gray;">;</span><span style="color: Blue;">FF</span><span style="color: Gray;">不能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">，但能识别!</span><span style="color: Blue;">important</span><span style="color: Gray;">;&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">写两句代码来控制一个属性，区别</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">与</span><span style="color: Blue;">IE6</span><span style="color: Gray;">：&nbsp;&nbsp; </span></li>
<li><span style="color: Blue;">background</span><span style="color: Navy;">:orange</span><span style="color: Gray;">;</span><span style="color: Blue;">*background</span><span style="color: Navy;">:blue</span><span style="color: Gray;">;&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">//这一句代码写出来时，你用</span><span style="color: Blue;">firefox</span><span style="color: Gray;">或其它非</span><span style="color: Blue;">IE</span><span style="color: Gray;">浏览时，会发现，写了该代码的区域背景是橙色的，如果用</span><span style="color: Blue;">IE</span><span style="color: Gray;">浏览，却是蓝色的，这是因为</span><span style="color: Blue;">IE</span><span style="color: Gray;">都能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">;标准浏览器(如</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">,</span><span style="color: Blue;">Opera</span><span style="color: Gray;">,</span><span style="color: Blue;">Netscape</span><span style="color: Gray;">)不能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">；&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">写两句代码来控制一个属性，区别</span><span style="color: Blue;">IE7</span><span style="color: Gray;">与</span><span style="color: Blue;">IE6</span><span style="color: Gray;">：&nbsp;&nbsp; </span></li>
<li><span style="color: Blue;">background</span><span style="color: Navy;">:green</span><span style="color: Gray;"> !</span><span style="color: Blue;">important</span><span style="color: Gray;">;</span><span style="color: Blue;">background</span><span style="color: Navy;">:blue</span><span style="color: Gray;">;&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">//这一句代码写出来时，你用</span><span style="color: Blue;">IE7</span><span style="color: Gray;">浏览，会发现，写了该代码的区域背景是绿色的，如果用</span><span style="color: Blue;">IE6</span><span style="color: Gray;">浏览，却是蓝色的，这是因为</span><span style="color: Blue;">IE7</span><span style="color: Gray;">能识别!</span><span style="color: Blue;">important*</span><span style="color: Gray;">，一但识别了，就执行，忽略了后面的那一句，但</span><span style="color: Blue;">IE6</span><span style="color: Gray;">却不能识别!</span><span style="color: Blue;">important</span><span style="color: Gray;">，所以前面部分跳过，直接执行了后半部份。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">写两句代码来控制一个属性，区别</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">与</span><span style="color: Blue;">IE</span><span style="color: Gray;">：&nbsp;&nbsp; </span></li>
<li><span style="color: Blue;">background</span><span style="color: Navy;">:orange</span><span style="color: Gray;">; </span><span style="color: Blue;">*background</span><span style="color: Navy;">:green</span><span style="color: Gray;">;&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">//这一句代码写出来时，你用</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">浏览，会发现背景是橙色的，而</span><span style="color: Blue;">IE</span><span style="color: Gray;">里却是绿色的，很简单，因为</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">不能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">，而</span><span style="color: Blue;">IE6</span><span style="color: Gray;">，</span><span style="color: Blue;">IE7</span><span style="color: Gray;">都可以识</span><span style="color: Blue;">*</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">写三句代码来控制一个属性，区别</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">，</span><span style="color: Blue;">IE7</span><span style="color: Gray;">，</span><span style="color: Blue;">IE6</span><span style="color: Gray;">：&nbsp;&nbsp; </span></li>
<li><span style="color: Blue;">background</span><span style="color: Navy;">:orange</span><span style="color: Gray;">;</span><span style="color: Blue;">*background</span><span style="color: Navy;">:green</span><span style="color: Gray;"> !</span><span style="color: Blue;">important</span><span style="color: Gray;">;</span><span style="color: Blue;">*background</span><span style="color: Navy;">:blue</span><span style="color: Gray;">;&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">//这一句会使在</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">在，背景呈橙色，</span><span style="color: Blue;">IE7</span><span style="color: Gray;">中为绿色，</span><span style="color: Blue;">IE6</span><span style="color: Gray;">中为蓝色，道理和前面一样，</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">不能识别</span><span style="color: Blue;">*</span><span style="color: Gray;">，所以后面两句都不执行，直接执行第一句，</span><span style="color: Blue;">IE7</span><span style="color: Gray;">当然也能执行第一行代码，但是因为第二句，他也能识别，所以就执行了第二句代码，把前面的效果给过滤了，而最后一句，</span><span style="color: Blue;">IE7</span><span style="color: Gray;">是不能识别的。</span><span style="color: Blue;">IE6</span><span style="color: Gray;">不能识别!</span><span style="color: Blue;">imprtant</span><span style="color: Gray;">，本来运行了第一句代码了，第二句不能识别，那就理所当然的执行了最后一句。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">以上</span><span style="color: Blue;">HACK</span><span style="color: Gray;">用法，可以实现不同浏览器的</span><span style="color: Blue;">CSS</span><span style="color: Gray;">代码，但是却不能通过</span><span style="color: Blue;">CSS</span><span style="color: Gray;">代码验证工具的验证！其实通不通过都无所谓，主要是实用，至少我是这样认为。如果你想要写能通过验证的</span><span style="color: Blue;">HACK</span><span style="color: Gray;">。那么请继续往下看第二种方案。</span></li></ol></div>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;经典方案二&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</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;">*</span><span style="color: Gray;"> </span><span style="color: Blue;">html</span><span style="color: Gray;">,</span><span style="color: Blue;">*</span><span style="color: Gray;"> +</span><span style="color: Blue;">html</span><span style="color: Gray;">的</span><span style="color: Blue;">hack</span><span style="color: Gray;">写法，此方法可以通过</span><span style="color: Blue;">CSS</span><span style="color: Gray;">验证，也比较规范。哈哈，</span><span style="color: Blue;">HACK</span><span style="color: Gray;">本来是不归范的产物，只是我个人认为这种</span><span style="color: Blue;">Hack</span><span style="color: Gray;">写法是</span><span style="color: Blue;">Hack</span><span style="color: Gray;">写法中的规范而已，不要拿东西砸我！！！&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">我写一个例子&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Blue;">#sample</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span><span style="color: Green;">background:</span><span style="color: #00008b;">red</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Blue;">*</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">html</span><span style="color: Gray;"> </span><span style="color: Blue;">#sample</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Green;">backgroud:</span><span style="color: #00008b;">green</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Blue;">*</span><span style="color: Gray;"> +</span><span style="color: Blue;">html</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">#sample</span><span style="color: Olive;">{</span><span style="color: Green;">backgroud:</span><span style="color: #00008b;">blue</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">在</span><span style="color: Blue;">DW</span><span style="color: Gray;">中建立一个</span><span style="color: Blue;">sample</span><span style="color: Gray;">层，写入以上代码，运行一下看看，你会在</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">或是</span><span style="color: Blue;">Netscape</span><span style="color: Gray;">或</span><span style="color: Blue;">Opera</span><span style="color: Gray;">中看到，</span><span style="color: Blue;">sample</span><span style="color: Gray;">的背景色是红色的。在</span><span style="color: Blue;">IE6</span><span style="color: Gray;">中看到背景色是绿色的，而在</span><span style="color: Blue;">IE7</span><span style="color: Gray;">中却是蓝色的。好玩吧~&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">同样，你也可以应用到</span><span style="color: Blue;">class</span><span style="color: Gray;">和</span><span style="color: Blue;">body</span><span style="color: Gray;">中去，一样的道理，三个写法:&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">第一个是标准写法，针对所有浏览器都有效，但是一样的</span><span style="color: Blue;">CSS</span><span style="color: Gray;">在不同的浏览器中会变形，这个道理你明白吧，要不然你也不会来看我这篇文章了。</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">,</span><span style="color: Blue;">Oprea</span><span style="color: Gray;">等非</span><span style="color: Blue;">IE</span><span style="color: Gray;">浏览器，不识别下面两种写法，所以理所当然的执行了第一种</span><span style="color: Blue;">CSS</span><span style="color: Gray;">代码，为红色背景。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">第二个是只针对</span><span style="color: Blue;">IE6</span><span style="color: Gray;">，只有</span><span style="color: Blue;">IE6</span><span style="color: Gray;">会执行，其它浏览器都不执行。那么</span><span style="color: Blue;">Firefox</span><span style="color: Gray;">,</span><span style="color: Blue;">IE7</span><span style="color: Gray;">都不会读到这里的代码，</span><span style="color: Blue;">IE6</span><span style="color: Gray;">本来第一种是能执行的，可是因为第二种能识别，所以过滤了第一种的红色效果，变成了绿色背景。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">第三个只针对</span><span style="color: Blue;">IE7</span><span style="color: Gray;">，只有</span><span style="color: Blue;">IE7</span><span style="color: Gray;">才能执行。</span><span style="color: Blue;">IE6</span><span style="color: Gray;">，</span><span style="color: Blue;">firefox</span><span style="color: Gray;">都不识别，当然只有</span><span style="color: Blue;">IE7</span><span style="color: Gray;">自己执行啦，同样的道理，能执行第一种，变成红色，可又被第三种过滤成蓝色背景。</span></li></ol></div>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;经典方案三&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</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;">第一种或是第二种方案，写出来的CSS文件代码长的很，特别是第二种，这样载入CSS时，会很缓慢，对网站设计没有好处。如果你做的是比较大的网站，还是建议你用下面这种方法，就是通过javascript判断浏览器的类型，然后针对不同的浏览器链接不同的CSS文件。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">我们针对不同的浏览器开发出不同的CSS文件，一个针对IE，一个针对Firefox，一个针对其它所有类型的浏览。这样，我们在设计时，就不用去考虑太多，只要我这个CSS能在FF中正常显示，我就不管IE下执行下怎么样了，同样IE中正常的CSS，也不去管它在FF中会是显示如何的乱。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">首先，我们在HTML代码里要放入</span><span style="color: Olive;">&lt;</span><span style="color: Green;">link</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">link</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">标签，标签里先写入默认要用到的CSS文件的位置，建议放IE中用到的CSS文件，比如</span><span style="color: Olive;">&lt;</span><span style="color: Green;">link</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;">../css/ie.css</span><span style="color: #8b0000;">&quot;</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</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: Olive;">&gt;</span><span style="color: Gray;">，这样能避免在对方浏览器没有开启javascript的时候，无法判断浏览器类型的时候，也能以90%以上人使用的IE正常显示。&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">把下面这段JS放在HEAD中&nbsp;&nbsp; </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;">LANGUAGE</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">JavaScript</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">&lt;!--&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">if (window.navigator.userAgent.indexOf(&quot;MSIE&quot;)&gt;=1)&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">{&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">//如果浏览器为IE，调用../css/ie.css&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">setActiveStyleSheet(&quot;ie.css&quot;);&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">}else{&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">if (window.navigator.userAgent.indexOf(&quot;Firefox&quot;)&gt;=1)&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">{&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">//如果浏览器为Firefox，调用../css/firefox.css&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">setActiveStyleSheet(&quot;firefox.css&quot;);&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">}else{&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">//如果浏览器为其他，调用../css/other.css&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">setActiveStyleSheet(&quot;other.css&quot;);&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">}&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">}&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">&nbsp; </span></li>
<li><span style="color: #ffa500;">function setActiveStyleSheet(title){&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp; &nbsp; document.getElementsByTagName(&quot;link&quot;)[0].href=&quot;../css/&quot;+title;&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">//document.getElementsByTagName(&quot;link&quot;)[0].href=&quot;/blog/css/&quot;+title; 这一行中的0是指第一个名为&lt;link&gt;的标签，改为1，则表示第二个名为&lt;link&gt;的标签。href=“”里面就是放置 CSS文件的路径，而title就是CSS文件的文件名&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">}&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">//--&gt;</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">SCRIPT</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">&nbsp;&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Gray;">window.navigator.userAgent.indexOf后面是浏览器的类型，如果是Opera的话，还可以加一条if来判断，用javascript 的条件判断去写吧，我这里不多说了。</span></li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/firefox-ie7-ie6-jianrongjiejuefangfa.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用css来控制图片显示大小</title>
		<link>http://www.sunle.net/css-control-pic-show-size.html</link>
		<comments>http://www.sunle.net/css-control-pic-show-size.html#comments</comments>
		<pubDate>Thu, 18 Dec 2008 12:01:22 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[图片显示]]></category>
		<category><![CDATA[大小]]></category>
		<category><![CDATA[显示]]></category>

		<guid isPermaLink="false">http://www.sunle.net/?p=542</guid>
		<description><![CDATA[<p>有时候图片太大，会破环网页整齐的布局。这时可以用css来强制按比例压缩图片的高度或宽度 </p>
<p>css代码如下： </p>
<p>++CoolCode_BLOCK_59++</p>
<p>这样当图片的高度或宽度若超过590px，将会按比例压缩成590px，如果不超过则按原大小显示。</p><p><a href='http://www.sunle.net/css-control-pic-show-size.html' rel="nofollow">点击阅读全文</a></p>]]></description>
			<content:encoded><![CDATA[<p>有时候图片太大，会破环网页整齐的布局。这时可以用css来强制按比例压缩图片的高度或宽度 </p>
<p>css代码如下： </p>
<p>++CoolCode_BLOCK_60++</p>
<p>这样当图片的高度或宽度若超过590px，将会按比例压缩成590px，如果不超过则按原大小显示。</p><p><a href='http://www.sunle.net/css-control-pic-show-size.html' rel="nofollow">点击阅读全文</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/css-control-pic-show-size.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIV 图片居中</title>
		<link>http://www.sunle.net/div-pic-cente%e5%b1%85%e4%b8%ad.html</link>
		<comments>http://www.sunle.net/div-pic-cente%e5%b1%85%e4%b8%ad.html#comments</comments>
		<pubDate>Mon, 10 Nov 2008 11:20:17 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[图片居中]]></category>
		<category><![CDATA[居中]]></category>

		<guid isPermaLink="false">http://www.sunle.net/111?p=445</guid>
		<description><![CDATA[<p>++RunCode_BLOCK_PrHSAW++</p>
<p>代码：<br />
<span id="more-445"></span></p>
<p>++CoolCode_BLOCK_61++</p><p><a href='http://www.sunle.net/div-pic-cente%e5%b1%85%e4%b8%ad.html' rel="nofollow">点击阅读全文</a></p>]]></description>
			<content:encoded><![CDATA[<p>++RunCode_BLOCK_vFWqKA++</p>
<p>代码：<br />
<span id="more-445"></span></p>
<p>++CoolCode_BLOCK_62++</p><p><a href='http://www.sunle.net/div-pic-cente%e5%b1%85%e4%b8%ad.html' rel="nofollow">点击阅读全文</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/div-pic-cente%e5%b1%85%e4%b8%ad.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>菜单点击弹出下拉式</title>
		<link>http://www.sunle.net/%e8%8f%9c%e5%8d%95%e7%82%b9%e5%87%bb%e5%bc%b9%e5%87%ba%e4%b8%8b%e6%8b%89%e5%bc%8f.html</link>
		<comments>http://www.sunle.net/%e8%8f%9c%e5%8d%95%e7%82%b9%e5%87%bb%e5%bc%b9%e5%87%ba%e4%b8%8b%e6%8b%89%e5%bc%8f.html#comments</comments>
		<pubDate>Fri, 07 Nov 2008 15:35:34 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[菜单]]></category>

		<guid isPermaLink="false">http://www.sunle.net/111?p=444</guid>
		<description><![CDATA[<p>ff</p><p><a href='http://www.sunle.net/%e8%8f%9c%e5%8d%95%e7%82%b9%e5%87%bb%e5%bc%b9%e5%87%ba%e4%b8%8b%e6%8b%89%e5%bc%8f.html' rel="nofollow">点击阅读全文</a></p>]]></description>
			<content:encoded><![CDATA[<p>ff</p><p><a href='http://www.sunle.net/%e8%8f%9c%e5%8d%95%e7%82%b9%e5%87%bb%e5%bc%b9%e5%87%ba%e4%b8%8b%e6%8b%89%e5%bc%8f.html' rel="nofollow">点击阅读全文</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/%e8%8f%9c%e5%8d%95%e7%82%b9%e5%87%bb%e5%bc%b9%e5%87%ba%e4%b8%8b%e6%8b%89%e5%bc%8f.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS三栏布局中最先显示中栏的方法</title>
		<link>http://www.sunle.net/css%E4%B8%89%E6%A0%8F%E5%B8%83%E5%B1%80%E4%B8%AD%E6%9C%80%E5%85%88%E6%98%BE%E7%A4%BA%E4%B8%AD%E6%A0%8F%E7%9A%84%E6%96%B9%E6%B3%95.html</link>
		<comments>http://www.sunle.net/css%E4%B8%89%E6%A0%8F%E5%B8%83%E5%B1%80%E4%B8%AD%E6%9C%80%E5%85%88%E6%98%BE%E7%A4%BA%E4%B8%AD%E6%A0%8F%E7%9A%84%E6%96%B9%E6%B3%95.html#comments</comments>
		<pubDate>Mon, 27 Oct 2008 17:17:38 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[网站制作]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[显示]]></category>
		<category><![CDATA[顺序]]></category>

		<guid isPermaLink="false">http://www.sunle.net/111?p=437</guid>
		<description><![CDATA[浏览器显示页面是一行一行的按顺序执行代码，也就是说写在前面的先执行显示，而对于左中右3栏布局的设计，代码要么是从左&#8211;>中&#8211;>右来书写，要么就是到过来从右&#8211;>中&#8211;>左来书写，要做到要求的效果，那首先要书写的是中栏的代码。所以我首先定义了一个id=m的DIV，并且padding-left:150px，定义这个是为了给左栏留出140PX的显示位置，然后再在这个DIV里面嵌套定义一个id=middle的DIV，我用position:absolute的属性(绝对定位);然后再定义左栏left和右栏right。用position:absolute的属性有一个不好的地方就是它象photoshop里的层一样，它的自动延伸并不会带动整个布局的延伸，所以会遮住一些页面元素，比如我们通常会在网站的最下面写上一些copyright的信息，如果用先显示中栏的这种方法，如果不做处理的话，这些信息会被遮盖住。处理的办法就是使用javascript,让左右2栏的高度随中栏一起自动延伸。以下为引用的内容： &#60;script language=&#34;javascript&#34;&#62; var l=document.getElementById(&#34;left&#34;).scrollHeight var m=document.getElementById(&#34;middle&#34;).scrollHeight var r=document.getElementById(&#34;right&#34;).scrollHeight layoutHeight=Math.max(l,m,r) document.getElementById(&#34;left&#34;).style.height=layoutHeight+&#34;px&#34; document.getElementById(&#34;right&#34;).style.height=layoutHeight+&#34;px&#34; document.getElementById(&#34;middle&#34;).style.height=layoutHeight+&#34;px&#34; &#60;/script&#62;]]></description>
			<content:encoded><![CDATA[<p>浏览器显示页面是一行一行的按顺序执行代码，也就是说写在前面的先执行显示，而对于左中右3栏布局的设计，代码要么是从左&#8211;>中&#8211;>右来书写，要么就是到过来从右&#8211;>中&#8211;>左来书写，要做到要求的效果，那首先要书写的是中栏的代码。<br/><br/>所以我首先定义了一个id=m的DIV，并且padding-left:150px，定义这个是为了给左栏留出140PX的显示位置，然后再在这个DIV里面嵌套定义一个id=middle的DIV，我用position:absolute的属性(绝对定位);然后再定义左栏left和右栏right。用position:absolute的属性有一个不好的地方就是它象photoshop里的层一样，它的自动延伸并不会带动整个布局的延伸，所以会遮住一些页面元素，比如我们通常会在网站的最下面写上一些copyright的信息，如果用先显示中栏的这种方法，如果不做处理的话，这些信息会被遮盖住。处理的办法就是使用javascript,让左右2栏的高度随中栏一起自动延伸。<span id="more-437"></span><br/><br/>以下为引用的内容：<br/><br/>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;script language=&quot;javascript&quot;&gt;</li>
<li>var l=document.getElementById(&quot;left&quot;).scrollHeight</li>
<li>var m=document.getElementById(&quot;middle&quot;).scrollHeight</li>
<li>var r=document.getElementById(&quot;right&quot;).scrollHeight</li>
<li>layoutHeight=Math.max(l,m,r)</li>
<li>document.getElementById(&quot;left&quot;).style.height=layoutHeight+&quot;px&quot;</li>
<li>document.getElementById(&quot;right&quot;).style.height=layoutHeight+&quot;px&quot;</li>
<li>document.getElementById(&quot;middle&quot;).style.height=layoutHeight+&quot;px&quot;</li>
<li>&lt;/script&gt;</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/css%E4%B8%89%E6%A0%8F%E5%B8%83%E5%B1%80%E4%B8%AD%E6%9C%80%E5%85%88%E6%98%BE%E7%A4%BA%E4%B8%AD%E6%A0%8F%E7%9A%84%E6%96%B9%E6%B3%95.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE多版本共存的解决方案——IETester（推荐）</title>
		<link>http://www.sunle.net/ietester.html</link>
		<comments>http://www.sunle.net/ietester.html#comments</comments>
		<pubDate>Mon, 01 Sep 2008 22:59:21 +0000</pubDate>
		<dc:creator>sunle</dc:creator>
				<category><![CDATA[资源共享]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie5]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[ietester]]></category>
		<category><![CDATA[软件]]></category>

		<guid isPermaLink="false">http://www.sunle.net/111?p=407</guid>
		<description><![CDATA[刚刚用过，感觉特别；厉害，比以前网上流行的Multiple IEs 强多啦！以下为官方解释： IETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE8 beta 1, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process. New in v0.2 : IE7 and IE8 beta 1 added ! This is an [...]]]></description>
			<content:encoded><![CDATA[<p>刚刚用过，感觉特别；厉害，比以前网上流行的Multiple IEs 强多啦！以下为官方解释：<br/><a href="http://www.sunle.net/wp-content/bo/attachment/1220281126_392182cb.jpg" rel="lightbox"><img src="http://www.sunle.net/wp-content/bo/attachment/1220281126_392182cb.jpg" class="insertimage"  border="0"/></a><span id="more-407"></span><br />
<a href="http://www.sunle.net/wp-content/uploads/2008/09/ietester-0_3.png" rel="lightbox"><img src="http://www.sunle.net/wp-content/uploads/2008/09/ietester-0_3-550x318.png" alt="ietester-0_3" title="ietester-0_3" width="550" height="318" class="aligncenter size-medium wp-image-916" /></a><br />
<br/>IETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE8 beta 1, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process. <br/>New in v0.2 : IE7 and IE8 beta 1 added ! <br/><br/>This is an alpha release, so feel free to post comments/bugs on the IETester forum or contact me directly. <br/><br/>Minimum requirement : Windows Vista or Windows XP with IE7 (Windows XP with IE6 has some minor problems and IE7/IE8 instances do not work under this config)<br/>最小需求：Windows Vista 或者 Windows XP 安装 IE7 版本( 如果安装的 IE6 版本 ，则Windows XP 下的 IE6 有一些小问题，并且在这个配置下 IE7/IE8 版本不能运行 )<br/><br/>不过任何软件都有不完美之处——<br/><br/>IETester 目前已知的问题有：<br/><br/>当窗口大小改变的时候，页面内容可能会消失（作者改进中）； <br/>上一页/下一页功能不正常； <br/>Focus功能不正常； <br/>Java apple不能运行； <br/>Flash不能在IE6下正常运行。 <br/>最新版本：v0.3.3 <a href="http://www.my-debugbar.com/ietester/install-ietester-v0.3.3.exe" target="_blank">下载</a> <a href="http://www.my-debugbar.com/ietester/Chinese.lang" target="_blank">中文包</a> (加入Languages 文件夹，默认在 C:&#92;Program Files&#92;Core Services&#92;IETester ) </p>
<p>官方网站:http://www.my-debugbar.com/wiki/IETester/HomePage</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunle.net/ietester.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
