<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="ARTICLE @ XOOPS powered by FeedCreator" -->
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://waterlily-lsl.com//modules/article/xml.php/rdf/170/c2">
        <title>睡蓮‧池水間 :: 文章</title>
        <description>文章XML</description>
        <link>http://waterlily-lsl.com/modules/article/view.article.php/170/c2</link>
        <image rdf:resource="http://waterlily-lsl.com/modules/article/images/logo.png" />
       <dc:date>2012-05-24T00:41:48+02:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://waterlily-lsl.com/modules/article/view.article.php/170/c2"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://waterlily-lsl.com/modules/article/images/logo.png">
        <title>睡蓮‧池水間 :: 文章</title>
        <link>http://waterlily-lsl.com/modules/article/</link>
        <url>http://waterlily-lsl.com/modules/article/images/logo.png</url>
    </image>
    <item rdf:about="http://waterlily-lsl.com/modules/article/view.article.php/170/c2">
        <dc:format>text/html</dc:format>
        <dc:date>2009-04-04T23:20:00+02:00</dc:date>
        <dc:source>http://waterlily-lsl.com/modules/article/</dc:source>
        <dc:creator>睡蓮</dc:creator>
        <title>提升網站效能的 CSS Sprites</title>
        <link>http://waterlily-lsl.com/modules/article/view.article.php/170/c2</link>
        <description>類別: 語言集&lt;br /&gt;來源: (池水間)近來在為池水間進行網站優化，將XHTML和CSS代碼改良，其中CSS就首次使用了CSS Sprites技術，以提升網站效能。&lt;br /&gt;&lt;br /&gt;什麼是CSS Sprites？就是將多個圖片匯集到一個大圖片上，然後在CSS裡將每個使用不同背景圖路徑全部劃一改為集成圖片路徑，並給每個背景圖定位。&lt;br /&gt;&lt;br /&gt;例如下面的無序列表，每一個 li 標籤分別用五個不同背景圖：&lt;br /&gt;&lt;div class=&quot;xoopsCode&quot;&gt;&lt;p class=&quot;cTitle&quot;&gt;&lt;img class=&quot;icon-l&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif&quot; alt=&quot;&quot;/&gt;&lt;img class=&quot;icon-r&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif&quot; alt=&quot;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;
&amp;lt;ul&amp;gt;
&amp;lt;li class=&amp;quot;image1&amp;quot;&amp;gt; image1 背景 &amp;lt;/li&amp;gt;
&amp;lt;li class=&amp;quot;image2&amp;quot;&amp;gt; image2 背景 &amp;lt;/li&amp;gt;
&amp;lt;li class=&amp;quot;image3&amp;quot;&amp;gt; image3 背景 &amp;lt;/li&amp;gt;
&amp;lt;li class=&amp;quot;image4&amp;quot;&amp;gt; image4 背景 &amp;lt;/li&amp;gt;
&amp;lt;li class=&amp;quot;image5&amp;quot;&amp;gt; image5 背景 &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;在CSS裡給每個 li 設定不同背景圖片路徑：&lt;br /&gt;&lt;div class=&quot;xoopsCode&quot;&gt;&lt;p class=&quot;cTitle&quot;&gt;&lt;img class=&quot;icon-l&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif&quot; alt=&quot;&quot;/&gt;&lt;img class=&quot;icon-r&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif&quot; alt=&quot;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;
.images1 {background: url(image1.png) no-repeat;}
.images2 {background: url(image2.png) no-repeat;}
.images3 {background: url(image3.png) no-repeat;}
.images4 {background: url(image4.png) no-repeat;}
.images5 {background: url(image5.png) no-repeat;}
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;上面就用了五個不同的路徑，如將五個圖片匯集到一個圖片，路徑就只要劃一用同一個便可以了。這樣一來當網頁載入圖片時只需一次載入集成圖片，然後依據先前背景圖的定位而顯示出不同背景圖。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong class=&quot;A_strong&quot;&gt;圖片匯集&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;background:url(/uploads/article/images/CSS_Sprites_3.png) no-repeat 50% 0;height:450px;width:900px&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong class=&quot;A_strong&quot;&gt;定位&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;當匯集到一個圖片之後，如何為每個 li 標籤分別指定 &lt;span style=&quot;color: #00ff00;&quot;&gt;5to1_image.png&lt;/span&gt; 裡面的不同背景圖呢？&lt;br /&gt;&lt;br /&gt;下圖的每一個紅框所示為每個 li 要用的背景：&lt;br /&gt;&lt;div style=&quot;background:url(/uploads/article/images/CSS_Sprites_3.png) no-repeat 50% -470px;height:300px;width:900px&quot;&gt;&lt;/div&gt;&lt;br /&gt;在為每個不同背景圖定位之前，須先給每個 li 標籤指定寬和高也就是100 px *  30px，如此定位才會準確。&lt;br /&gt;&lt;br /&gt;上面的image1 ，其灰色背景位處在 &lt;span style=&quot;color: #00ff00;&quot;&gt;5to1_image.png&lt;/span&gt; 裡的最上面，也就是最容易定位的地方：&lt;br /&gt;&lt;div class=&quot;xoopsCode&quot;&gt;&lt;p class=&quot;cTitle&quot;&gt;&lt;img class=&quot;icon-l&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif&quot; alt=&quot;&quot;/&gt;&lt;img class=&quot;icon-r&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif&quot; alt=&quot;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;
.images1 {background: url(5to1_image.png) no-repeat &lt;span style=&quot;color: #ff0000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt;;}
&lt;/pre&gt;&lt;/div&gt;上面代碼中紅色的0為x，藍色的0為y；x為水平位置，y為垂直位置。&lt;br /&gt;&lt;br /&gt;由於背景圖定位的預設值皆為0的關係，上面的代碼可以省略成如下：&lt;br /&gt;&lt;div class=&quot;xoopsCode&quot;&gt;&lt;p class=&quot;cTitle&quot;&gt;&lt;img class=&quot;icon-l&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif&quot; alt=&quot;&quot;/&gt;&lt;img class=&quot;icon-r&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif&quot; alt=&quot;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;
.images1 {background: url(5to1_image.png) no-repeat;}
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;好了，接下來給 image2 定位，其藍色背景位處在灰色的下面，見下圖：&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;background:url(/uploads/article/images/CSS_Sprites_3.png) no-repeat 70% -790px;height:250px;width:900px&quot;&gt;&lt;/div&gt;&lt;br /&gt;將 image2 的藍背景向上提升一格( 30px )至紅框位置，而水平位置維持不變：&lt;br /&gt;&lt;div class=&quot;xoopsCode&quot;&gt;&lt;p class=&quot;cTitle&quot;&gt;&lt;img class=&quot;icon-l&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif&quot; alt=&quot;&quot;/&gt;&lt;img class=&quot;icon-r&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif&quot; alt=&quot;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;
.images2 {background: url(5to1_image.png) no-repeat 0 &lt;span style=&quot;color: #ffac00;&quot;&gt;-30px&lt;/span&gt;;}
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;接著將位處在image 2 下面的 image 3 ，向上提升兩格至紅框，兩格就是60px。其他的image 4 和 image 5 則餘類推：&lt;br /&gt;&lt;div class=&quot;xoopsCode&quot;&gt;&lt;p class=&quot;cTitle&quot;&gt;&lt;img class=&quot;icon-l&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif&quot; alt=&quot;&quot;/&gt;&lt;img class=&quot;icon-r&quot; src=&quot;http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif&quot; alt=&quot;&quot;/&gt;&lt;/p&gt;&lt;pre&gt;
.images3 {background: url(5to1_image.png) no-repeat 0 &lt;span style=&quot;color: #ffac00;&quot;&gt;-60px&lt;/span&gt;;}
.images4 {background: url(5to1_image.png) no-repeat 0 &lt;span style=&quot;color: #ffac00;&quot;&gt;-90px&lt;/span&gt;;}
.images5 {background: url(5to1_image.png) no-repeat 0 &lt;span style=&quot;color: #ffac00;&quot;&gt;-120px&lt;/span&gt;;}
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;CSS Sprites 就是這樣用法，除了上面的多圖匯集成一圖之外，CSS Sprites亦可取代以往在photoshop繪製好設計圖後需作切圖的舊模式，利用CSS Sprites技術，便可不需切圖而直接使用了。&lt;br /&gt;</description>
    </item>
</rdf:RDF>

