<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="ARTICLE @ XOOPS powered by FeedCreator" -->
<rss version="0.91">
    <channel>
        <title>睡蓮‧池水間 :: 文章</title>
        <description><![CDATA[文章XML]]></description>
        <link>http://waterlily-lsl.com/modules/article/view.article.php/179/c2</link>
        <lastBuildDate>Thu, 24 May 2012 01:23:23 +0200</lastBuildDate>
        <generator>ARTICLE @ XOOPS powered by FeedCreator</generator>
        <image>
            <url>http://waterlily-lsl.com/modules/article/images/logo.png</url>
            <title>睡蓮‧池水間 :: 文章</title>
            <link>http://waterlily-lsl.com/modules/article/</link>
            <width>92</width>
            <height>52</height>
            <description>文章XML</description>
        </image>
        <language>zh-TW</language>
        <managingEditor>waterlily at waterlily-lsl dot com</managingEditor>
        <webMaster>waterlily at waterlily-lsl dot com</webMaster>
        <category>文章</category>
        <item>
            <title>解決IE 7、8下的 object 框線問題</title>
            <link>http://waterlily-lsl.com/modules/article/view.article.php/179/c2</link>
            <description><![CDATA[類別: 語言集<br />來源: (池水間)iframe 是最常見的網頁嵌入標籤，但到了XHTML 1.0 Stict 之下，這種標籤便不允許使用了。需要嵌入網頁，可以用object標籤取替之。<br /><br />

object標籤用途廣，除了可嵌入網頁、媒體外，還可取代 img標籤之用等。但IE對object的支援尚不完全，即使是開始支援網頁標準的最新版IE 8，仍有不完美的地方。<br /><br />

例如在取代 iframe 作為網頁嵌入上，標準瀏覽器下可以給object設定為border:none以去除框線，但在IE下是無效。IE的各個版本中，IE 6甚或較低版本的IE5.5可以改為通過在嵌入的網頁裡頭設定html與body為border:none，較高的兩個版本還不行，依然顯示礙眼的框線。<br /><br />
<table id="artContable4">
<tr><th></th><th>標準瀏覽器</th><th>IE 6 / IE5.5</th><th>IE 7</th><th>IE 8</th></tr>
<tr><td>object {     border:none     }</td><td class="passed">Y</td><td>N</td><td>N</td><td>N</td></tr>
<tr><td>html, body {     border:none     }</td><td class="passed">Y</td><td class="passed">Y</td><td>N</td><td>N</td></tr>
</table>
<br />
下面各圖是在嵌入的網頁裡設定語法後的結果，其中overflow:hidden為隱藏捲軸。
<span style="background:url(/uploads/article/images/090531.png) no-repeat 50% 0;height:700px;display:block"><!-- image --></span>
<br />
針對 IE 7 和 IE 8 的問題，想出了使用 clip 屬性來對付頑固的框線，將那礙眼的東西裁切掉。
<br /><br />
在設定裁切數值之前，先來看看框架語法：
<div class="xoopsCode"><p class="cTitle"><img class="icon-l" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif" alt=""/><img class="icon-r" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif" alt=""/></p><pre>
&lt;div&gt;
&lt;object type=&quot;text/html&quot; data=&quot;嵌入的網址&quot; width=&quot;300&quot; height=&quot;200&quot;&gt;
&lt;p&gt;閣下瀏覽器不支援此框架&lt;/p&gt;
&lt;/object&gt;
&lt;/div&gt;
</pre></div>
<br />
上面容器裡object 的寬為300，高為200，IE 7 和 IE 8 的每邊框線寬度皆為2px，那麼CSS裡clip的屬性值依上右下左順序設為：
<div class="xoopsCode"><p class="cTitle"><img class="icon-l" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif" alt=""/><img class="icon-r" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif" alt=""/></p><pre>
object{
    clip:rect(2px, 298px, 198px, 2px);
}
</pre></div>
<br />
IE 8已支援兩個數值之間帶如上的標準逗號，而IE 7則只支援沒有逗號：
<div class="xoopsCode"><p class="cTitle"><img class="icon-l" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif" alt=""/><img class="icon-r" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif" alt=""/></p><pre>
object{
clip:rect(數值 數值 數值 數值);
}
</pre></div>
<br />
來說明一下上面的數值是如何計算得來的：
<br /><br />
首先說說第一個數值，也就是上邊的數值，由邊框外緣的左上角為起點，向下移至2px位置裁切。(下圖1)<br />
第二個數值為右邊，自左上角向右移至298px。(下圖2)<br />
第三個數值為下邊，自左上角向下移至198px。(下圖3)<br />
第四個數值為左邊，自左上角向右移至2px。(下圖4)<br />
<br />
放大圖：
<br /><br />
<span style="background:url(/uploads/article/images/090601cut.png) no-repeat 50% 0;height:600px;display:block"><!-- image --></span>
<br />
使用clip屬性時，必須同時使用「絕對定位」 方為有效，並給上一層的 div 設「相對定位」，如此「絕對定位」會以 div 為起點，不會跑到頁面的左上角去。

<div class="xoopsCode"><p class="cTitle"><img class="icon-l" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon1.gif" alt=""/><img class="icon-r" src="http://waterlily-lsl.com/themes/waterlilyLSL-GW/img/code-icon2.gif" alt=""/></p><pre>
div{
     position:relative; <span style="color: #ffac00;">/* 相對定位 */</span>
} 
object{
    position:absolute; <span style="color: #ffac00;">/* 絕對定位 */</span>
    clip:rect(2px, 296px, 198px, 2px); <span style="color: #ffac00;">/* 帶逗號為IE 8，IE 7 要不帶逗號 */</span>
}
</pre></div>
<br />
裁切後：
<span style="background:url(/uploads/article/images/090601.png) no-repeat 50% 0;height:320px;display:block"><!-- image --></span><br />]]></description>
            <author>睡蓮</author>
            <pubDate>Mon, 01 Jun 2009 14:42:54 +0200</pubDate>
        </item>
    </channel>
</rss>

