我在谷歌瀏覽器中的svg list-style-image中遇到了一些奇怪的問題。webkit中的list-style-image svg較小
.services ul {
list-style-image: url('images/check.svg');
list-style-position: inside;
padding: 0;
margin: 0;
}
圖像大小應該是16px x 16px。但它看起來比較小,大小約爲一半。如果我切換到PNG,大小是正確的。在其他瀏覽器中,它似乎是好的。
任何想法?由於您正在調用SVG圖像,因此您可能會收到以下錯誤信息:
我想從CSS調用SVG,而不必將svg代碼添加到我的html中。我對背景圖像做了同樣的處理,沒有任何問題。 – Jando
@Jando你必須在你的'class'中定義width和height屬性。通過添加'width'和'height'讓我知道你的作品。 –
啊,是的,你是對的。設置列表樣式圖像的寬度和高度是不可能的,所以我發現了這項工作: .services li:{ \t content:''; \t display:inline-block; \t身高:1em; \t width:1em; \t background-image:url('images/check.svg'); \t background-size:contains; \t background-repeat:no-repeat; \t padding-left:2em; } – Jando