我想製作一個CSS樣式表,允許完全沒有經驗的用戶(使用所見即所得編輯器)在PDF鏈接旁邊有PDF圖標。但是,這可能會導致不同字體大小的圖像的不必要的伸展。 有沒有什麼方法可以告訴用戶應用這些錨點的字體大小,然後應用正確的圖標?CSS選擇器地址線高度?
我希望的,因爲這簡單的東西:
:link[href$=".pdf"]::after,
:visited[href$=".pdf"]::after{
background-size: 1em !important;
background-repeat: no-repeat !important;
background-position: 100% 50% !important;
color:inherit !important;
content:" " !important;
padding-right:1.5em !important;
text-decoration:inherit !important;
}
:link[href$=".pdf"]::after,
:visited[href$=".pdf"]::after{
background-image:url('/images/MIME_PDF_16px.png');
}
:link[href$=".pdf"][style.line-height>16px]::after,
:visited[href$=".pdf"][style.line-height>16px]::after{
background-image:url('/images/MIME_PDF_32px.png');
}
:link[href$=".pdf"][style.line-height>32px]::after,
:visited[href$=".pdf"][style.line-height>32px]::after{
background-image:url('/images/MIME_PDF_48px.png');
}
:link[href$=".pdf"][style.line-height>48px]::after,
:visited[href$=".pdf"][style.line-height>48px]::after{
background-image:url('/images/MIME_PDF_64px.png');
}
:link[href$=".pdf"][style.line-height>64px]::after,
:visited[href$=".pdf"][style.line-height>64px]::after{
background-image:url('/images/MIME_PDF_128px.png');
}
或者,這樣的事情將是很好:
:link[href$=".pdf"]::after,
:visited[href$=".pdf"]::after{
background-size: 1em !important;
background-repeat: no-repeat !important;
background-position: 100% 50% !important;
color:inherit !important;
content:" " !important;
padding-right:1.5em !important;
text-decoration:inherit !important;
}
:link[href$=".pdf"]::after,
:visited[href$=".pdf"]::after{
background-image:16px 16px url('/images/MIME_PDF_16px.png'),
32px 32px url('/images/MIME_PDF_32px.png'),
48px 48px url('/images/MIME_PDF_48px.png'),
64px 64px url('/images/MIME_PDF_64px.png'),
url('/images/MIME_PDF_128px.png');
}
如果沒有這樣的選擇或價值存在,那麼我應該把它提交給W3C? 這會違背CSS的哲學嗎?
我不認爲是循環使用CSS的問題,由於其級聯的性質。它應該簡單地說就是無論哪個屬性匹配得最好,或者文件更遠,都是應用的屬性。對於你的'[display = block] {display:none; } [display = none] {display:block; }例如,應該是第一個選擇器被應用,然後第二個,然後停止。 – Supuhstar 2013-02-12 17:53:28
我沒有看過SVG。你可以設置它以不同的分辨率顯示不同的圖像?此外,這是一個網站,目前支持IE8,所以我對使用SVG猶豫不決。令人驚訝的是,我所描述的MIME類型標籤在IE8上工作得很好(當然,對於不同的行高不需要不同的圖像) – Supuhstar 2013-02-12 17:55:54
@Supuhstar:這實際上是針對它的級聯性質......如果你需要IE8支持,那麼你需要使用單個冒號和僞元素(IE8不支持'background-size')。矢量圖像是一次繪製一次,不管如何調整大小,矢量圖像都可以平滑地縮放,而不會有任何質量損失或像素化。 – BoltClock 2013-02-12 17:56:03