2010-08-30 63 views
5

我正在使用-webkit-background-clip將背景圖像限制爲h2元素中的文本。CSS3 background-clip

我的問題是,用-moz-background-clip函數做同樣的方法嗎?這似乎只在WebKit瀏覽器工作,這表明它並沒有工作在Firefox:目前

#header h1 a{ 
    background: url(img/logo-overlay.png) no-repeat #000; 
    -moz-background-clip: text; -webkit-background-clip: text; 
    color: transparent; -moz-text-fill-color: transparent; -webkit-text-fill-color: transparent; 
    text-decoration: none; 
} 

,在Firefox,文本是隱藏的(因顏色:透明和文本填充顏色:透明屬性),並且只有背景圖像和顏色在元素的矩形形狀中可見。

任何想法?

回答

2

我不相信textbackground-clip屬性的有效值。

MDC聲明瞭兩個不同的聲明,一個用於Firefox 3.6及更低版本,另一個用於即將推出的Firefox 4.它也說明了webkit的等價物。

Firefox (Gecko)  
1.0-3.6 (1.2-1.9.2) -moz-background-clip: padding | border 
4.0 (2.0)    background-clip:  padding-box | border-box | content-box 

Safari (WebKit) 
3.0 (522)    -webkit-background-clip: padding | border | content 

看到這裏的MDC文件:https://developer.mozilla.org/en/CSS/background-clip

至於你想達到什麼目的,我相信content-box值是你在找什麼。請注意,Firefox 3.6及更低版本似乎不支持此值。

參見:http://www.css3.info/preview/background-origin-and-background-clip/

+0

有趣。 Webkit瀏覽器中的「文本」值能夠實現這一點(放大):http://cl.ly/2Ame。那麼,它現在必須完全專有於Webkit。使用內容框不起作用 - 呈現完全相同的結果,因爲完全忽略了背景剪輯。這應該是不同的行爲?感謝您的迴應。 – Gavin 2010-08-30 13:50:53

+0

'content-box'與'text'不一樣http://dabblet.com/gist/3180315 – 2012-07-26 05:00:02