<?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>Tomgo的生活博客 &#187; DIV+CSS网页重构</title>
	<atom:link href="http://www.54tomgo.com/archives/tag/divcss%e7%bd%91%e9%a1%b5%e9%87%8d%e6%9e%84/feed" rel="self" type="application/rss+xml" />
	<link>http://www.54tomgo.com</link>
	<description>生活&#124;电影&#124;新闻&#124;IT话题</description>
	<lastBuildDate>Wed, 29 Jun 2011 06:41:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		
<!-- Start Of Script Generated By WP-PostViews Plus 1.1.18 -->
<script type='text/javascript' src='http://www.54tomgo.com/wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
jQuery.ajax({type:'GET',url:'http://www.54tomgo.com/wp-content/plugins/wp-postviews-plus/postviews_plus.php',data:'todowppvp=&type=tag&id=190_1',cache:false,dataType:'script'});/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus 1.1.18 -->
	<item>
		<title>使用DIV+CSS重构解决在Firefox变形的问题</title>
		<link>http://www.54tomgo.com/archives/663.html</link>
		<comments>http://www.54tomgo.com/archives/663.html#comments</comments>
		<pubDate>Thu, 26 Nov 2009 06:18:13 +0000</pubDate>
		<dc:creator>tomgo</dc:creator>
				<category><![CDATA[心得技巧]]></category>
		<category><![CDATA[DIV+CSS网页重构]]></category>

		<guid isPermaLink="false">http://www.54tomgo.com/?p=663</guid>
		<description><![CDATA[


div+css重构


一直以来都是使用table来建立网站，繁重的工作，臃肿的代码，每次想修改的时候，要重头在photoshop切图，再重新编辑，实在是累人，而且到最后在浏览器测试的时候，发现错误，又要重新修改。而且还要考虑到兼容firefox浏览器的问题。
这两天买了金峰老师编写的《变幻之美：DIV+CSS网页布局揭秘》，如获至宝。虽然以前对DIV+CSS有基础的学习，但是对PSD图片切图到对HTML的编写过程不多。看了30页后，我就决定对淘宝的旺铺进行修改，从而解决在firefox中的table变性的问题。
按照思路，我先把结构重构代码是
&#60;div id=&#34;notice&#34;&#62;
&#160;&#160; &#160; &#60;div id=&#34;zuo&#34;&#62;&#60;/div&#62;
&#160;&#160; &#160; &#60;div id=&#34;zhong&#34;&#62;&#60;/div&#62;
&#160;&#160; &#160; &#60;div id=&#34;you&#34;&#62;&#60;/div&#62;
&#60;/div&#62;
把广告为左中右三个结构。然后继续晚上结构。
&#60;div id=&#34;notice&#34;&#62;
&#160;&#160; &#160; &#60;div id=&#34;zuo&#34;&#62;&#60;/div&#62;
&#160;&#160; &#160; &#60;div id=&#34;zhong&#34;&#62;&#60;/div&#62;
&#160;&#160; &#160; &#60;div id=&#34;you&#34;&#62;
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#60;div id=&#34;youding&#34;&#62;&#60;/div&#62;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#60;div id=&#34;youdi&#34;&#62;&#60;/div&#62;
&#160;&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp mceIEcenter" style="text-align: center;">
<dl id="attachment_664" class="wp-caption aligncenter" style="width: 460px; text-align: center;">
<dt class="wp-caption-dt"><img class="size-full wp-image-664" title="div+css重构" src="http://www.54tomgo.com/wp-content/uploads/2009/11/divcss.jpg" alt="div+css重构" width="450" height="111" /></dt>
<dd class="wp-caption-dd">div+css重构</dd>
</dl>
</div>
<p>一直以来都是使用table来建立网站，繁重的工作，臃肿的代码，每次想修改的时候，要重头在photoshop切图，再重新编辑，实在是累人，而且到最后在浏览器测试的时候，发现错误，又要重新修改。而且还要考虑到兼容firefox浏览器的问题。<br />
这两天买了金峰老师编写的《变幻之美：DIV+CSS网页布局揭秘》，如获至宝。虽然以前对DIV+CSS有基础的学习，但是对PSD图片切图到对HTML的编写过程不多。看了30页后，我就决定对淘宝的旺铺进行修改，从而解决在firefox中的table变性的问题。<span id="more-663"></span><br />
按照思路，我先把结构重构代码是</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;div id=&quot;notice&quot;&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &lt;div id=&quot;zuo&quot;&gt;&lt;/div&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &lt;div id=&quot;zhong&quot;&gt;&lt;/div&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &lt;div id=&quot;you&quot;&gt;&lt;/div&gt;</li>
<li>&lt;/div&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">&lt;div id=&quot;notice&quot;&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &lt;div id=&quot;zuo&quot;&gt;&lt;/div&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &lt;div id=&quot;zhong&quot;&gt;&lt;/div&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &lt;div id=&quot;you&quot;&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div id=&quot;youding&quot;&gt;&lt;/div&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div id=&quot;youdi&quot;&gt;&lt;/div&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;&lt;/div&gt;</li>
<li>&lt;/div&gt;</li></ol></div>
<p>把右侧的上下架构定义出来。然后的工作就是做CSS的排版定位工作了。<br />
CSS代码也是慢慢的完善，这里我学习了金峰老师的良好习惯，把每个部位都定义背景色，这样就可以在排版错误后，看清楚错误在什么地方，修改就很方便了。使用Dreamweaver的CSS代码编写工具，可视化编辑，非常方便，不需要记住繁琐的CSS代码。最后代码如下：
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#notice {</li>
<li>	clear: both;</li>
<li>	margin: auto;</li>
<li>	height: 220px;</li>
<li>	width: 738px;</li>
<li>}</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; #notice #zuo {</li>
<li>	clear: none;</li>
<li>	float: left;</li>
<li>	height: 220px;</li>
<li>	width: 461px;</li>
<li>	background-image: url(images/divnotice_01.jpg);</li>
<li>	background-repeat: no-repeat;</li>
<li>}</li>
<li>&nbsp;#notice #zuo&nbsp; p {</li>
<li>	height: 170px;</li>
<li>	width: 368px;</li>
<li>	margin-top: 23px;</li>
<li>	margin-bottom: auto;</li>
<li>	margin-left: 26px;</li>
<li>	float: none;</li>
<li>	font-size: 12px;</li>
<li>	color: #FFFF00;	</li>
<li>&nbsp;}</li>
<li>#notice #zuo&nbsp; p&nbsp; a {</li>
<li>	font-size: 12px;</li>
<li>	color: #FFFF00;</li>
<li>	text-decoration: none;</li>
<li>	}</li>
<li>#notice #zuo&nbsp; p a:hover {</li>
<li>	font-size: 12px;</li>
<li>	color: #FFFF00;</li>
<li>	text-decoration: underline;</li>
<li>}</li>
<li>&nbsp;</li>
<li>#notice #zhong {</li>
<li>	</li>
<li>	float: left;</li>
<li>	height: 220px;</li>
<li>	width: 143px;</li>
<li>	background-image: url(images/divnotice_02.jpg);</li>
<li>}</li>
<li>	</li>
<li>	#notice #you {</li>
<li>	</li>
<li>	float: right;</li>
<li>	height: 220px;</li>
<li>	width: 134px; }</li>
<li>	</li>
<li>	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #notice #you #youding{</li>
<li>	</li>
<li>	clear: right;</li>
<li>	float: left;</li>
<li>	height: 111px;</li>
<li>	width: 134px;</li>
<li>&nbsp;	background-image: url(images/divnotice_03.jpg);</li>
<li>	background-repeat: no-repeat;</li>
<li>}</li>
<li>	</li>
<li>	#notice #you #youdi{</li>
<li>	background-color: #FF33FF;</li>
<li>	clear: both;</li>
<li>	float: left;</li>
<li>	height: 109px;</li>
<li>	width: 134px;}</li></ol></div>
<p>搞定后，想去淘宝直接使用发现一个难题，原来淘宝对CSS文件，是要过滤屏蔽的。而且也不能直接在网页定义
<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;style&gt;</li></ol></div>
<p>这个非常不爽。借鉴了一些装修店铺的方法，得到了解决之道。我把每个div层，都定义
<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;div id=&quot;notice&quot; style=&quot;这里复制层的CSS样式;&quot;&gt;</li></ol></div>
<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">&lt;div id=&quot;notice&quot; style=&quot;clear: both;</li>
<li>	margin: auto;</li>
<li>	height: 220px;</li>
<li>	width: 738px;&quot;&gt;</li>
<li>&nbsp;&nbsp; &nbsp;&lt;div id=&quot;zuo&quot; style=&quot;clear: none;</li>
<li>	float: left;</li>
<li>	height: 220px;</li>
<li>	width: 461px;</li>
<li>	background-image: url(http://www.yanwotang.com/taobao/divnotice_01.jpg);</li>
<li>	background-repeat: no-repeat; &quot;&gt;</li>
<li>&lt;p style=&quot;height: 170px;</li>
<li>	width: 368px;</li>
<li>	margin-top: 23px;</li>
<li>	margin-bottom: auto;</li>
<li>	margin-left: 26px;</li>
<li>	float: none;</li>
<li>	font-size: 12px;</li>
<li>	color: #FFFF00;	 &quot;&gt;&lt;img height=&quot;13&quot; alt=&quot;第一&quot; src=&quot;http://www.yanwotang.com/taobao/1.gif&quot; width=&quot;13&quot; /&gt;燕窝堂官方网站地址www.yanwotang.com，热线400-666-0092&lt;br /&gt;&lt;br /&gt;</li>
<li>&nbsp; &lt;img height=&quot;13&quot; alt=&quot;第二&quot; src=&quot;http://www.yanwotang.com/taobao/2.gif&quot; width=&quot;13&quot; /&gt;购买燕窝堂的正价燕窝，可以获得96折优惠。(&lt;a href=&quot;##&quot; target=&quot;_blank&quot;&gt;特价除外&lt;/a&gt;)</li>
<li>&nbsp; &lt;br /&gt;&lt;br /&gt;</li>
<li>&nbsp; &lt;img height=&quot;13&quot; alt=&quot;第三&quot; src=&quot;http://www.yanwotang.com/taobao/3.gif&quot; width=&quot;13&quot; /&gt;凡购买任意一两燕窝堂燕窝，送精美礼品。(&lt;a title=&quot;最新优惠活动&quot; href=&quot;http://shop34282253.taobao.com/shop/xshop/wui_page-16104846.htm&quot;&gt;礼品请见最新活动&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;</li>
<li>&nbsp; &lt;img height=&quot;13&quot; alt=&quot;第四&quot; src=&quot;http://www.yanwotang.com/taobao/4.gif&quot; width=&quot;13&quot; /&gt;单品种燕窝购买一斤或以上，可按照批发价格购买，批发包快递。&lt;br /&gt;&lt;br /&gt;</li>
<li>&nbsp; &lt;img height=&quot;13&quot; alt=&quot;第五&quot; src=&quot;http://www.yanwotang.com/taobao/5.gif&quot; width=&quot;13&quot; /&gt;&lt;a href=&quot;http://auction1.taobao.com/auction/item_detail-db1-d26069e6a0ec7982fd166a302e12dc08.jhtml&quot; target=&quot;_blank&quot;&gt;办理成为燕窝堂金卡会员，可终生享受正价燕窝9折优惠。&lt;/a&gt;&lt;br /&gt;</li>
<li>&nbsp; &lt;strong&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.yanwotang.com/taobao/taobaonew.gif&quot; border=&quot;0&quot; /&gt;&lt;/strong&gt; 好消息:&lt;a title=&quot;送燕窝食谱一本&quot; href=&quot;http://item.taobao.com/auction/item_detail-0db1-6177dcee426637f311383fb708506df7.htm&quot; target=&quot;_blank&quot;&gt;买即免费送《燕窝与其他保健品食谱》一本&lt;/a&gt;&lt;img alt=&quot;&quot; src=&quot;images/icon_notice_new.gif&quot; /&gt;</li>
<li>&nbsp;&nbsp; &nbsp;&lt;/div&gt;</li>
<li>	</li>
<li>	</li>
<li>	&lt;div style=&quot;float: left;</li>
<li>	height: 220px;</li>
<li>	width: 143px;</li>
<li>	background-image: url(http://www.yanwotang.com/taobao/divnotice_02.jpg); &quot;&gt; </li>
<li>	&lt;/div&gt;</li>
<li>	</li>
<li>	</li>
<li>	&lt;div id=&quot;you&quot; style=&quot; float: right;</li>
<li>	height: 220px;</li>
<li>	width: 134px;&quot;&gt;</li>
<li>	&lt;div id=&quot;youding&quot; style=&quot; clear: right;</li>
<li>	float: left;</li>
<li>	height: 111px;</li>
<li>	width: 134px;</li>
<li>&nbsp;	background-image: url(http://www.yanwotang.com/taobao/divnotice_03.jpg);</li>
<li>	background-repeat: no-repeat;&quot;&gt;&nbsp; &lt;/div&gt;</li>
<li>	&lt;div id=&quot;youdi&quot; style=&quot; 	background-color: #FF33FF;</li>
<li>	clear: both;</li>
<li>	float: left;</li>
<li>	height: 109px;</li>
<li>	width: 134px;&quot;&gt;&lt;a href=&quot;##&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://www.yanwotang.com/taobao/divnotice_04.jpg&quot; alt=&quot;收藏本店后,请通知我们客服送礼品&quot; border=&quot;0&quot;&nbsp; /&gt;&lt;/a&gt;&lt;/div&gt;</li>
<li>	</li>
<li>	&lt;/div&gt;</li>
<li>&nbsp;</li>
<li>&lt;/div&gt;</li></ol></div>
<p>这里纯粹记录我的学习过程，希望大家一起探讨CSS的乐趣。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.54tomgo.com/archives/663.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

