doubleluo(大菠萝)
.svg{
background-image:url(../img/a.svg);
}
<svg class="svg__vector-intro" viewBox="0 0 960 200">
<rect x="40.2" y="25.3" width="150" height="150"/>
<circle cx="354.4" cy="100.3" r="75"/>
<polygon points="593.6,25.3 617.9,74.7 672.4,82.6 633,121.1 642.3,175.3
593.6,149.7 544.8,175.3 554.1,121.1 514.7,82.6 569.2,74.7 "/>
<path d="M923,107.3C11.5,41.5 51.2,38.8 66.5,29.5C829,120
836.9,77.9 810,63.3C21.5 11.6 59 5 67.5,33.5"/>
</svg>
不止是变锐 而且变亮
扁平化的界面icon和少部分的效果
.svg{
background-image: url(svg.svg);
}
.png{
width: 40px;
height: 40px;
background-image: url(png.png);
@media query(min-device-pixel-ratio: 3){
background-image: url(png@3x.png);
background-size: 40px 40px;
}
}
.svg{
width: 40px;
height: 40px;
background-image:url(svg.svg);
}
.svg{
width: 40px;
height: 40px;
background-image: url(data:image/svg+xml;
base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy
53My5vcmcvMjAwMC9zdmciIHdpZHRoP
SIyIiBoZWlnaHQ9IjQ1OCIgdmlld0JveD0iM
CAwIDIgNDU4Ij4gIDxwb2x5bGluZSBmaWxs
PSJub25lIiBzdHJva2U9IiM5Nzk3OTciIHBvaW5
0cz0iMS4zNDQgLjQ2OSAxLjM0NCA1OS43ODEgMS4
zNDQgMjYxLjQzOCAxLjM0NCAzNzQuMTI1IDEuMzQ0IDQ
wOS42ODggMS4zNDQgNDI3LjUgMS4zNDQgNDUxLjI
xOSAxLjM0NCA0NTcuMTU2Ii8+PC9zdmc+);
}
.svg{
width: 40px;
height: 40px;
background-image: url("data:image/svg+xml,%3Csvg
xmlns='http://www.w3.org/2000/svg' width='2'
height='458' viewBox='0 0 2 458'%3E %3Cpolyline
fill='none' stroke='%23979797' points='1.344 .469
1.344 59.781 1.344 261.438 1.344 374.125 1.344
409.688 1.344 427.5 1.344 451.219 1.344 457.156'/
%3E %3C/svg%3E ");
}
SVGO
当我们需要全站REM统一多屏体验
.png{
width: 1.75rem;
height: 1.75rem;
background-image: url(spirte@2x.png);
background-position: 10px 10px;
background-size: 1.75rem 1.75rem;
}
Sprite和REM的坑
Sprite和REM的坑
1.75rem换算表
代表机型 | 浏览器宽 | 对应尺寸 |
---|---|---|
iPhone 4/4s/5/5s | 320px | 56px |
iPhone 6 | 375px | 65.625px |
Google Nexus 6 | 412px | 72.1px |
iPhone 6 Plus | 414px | 72.45px |
轻易的解决REM的问题
.svg{
width: 1.75rem;
height: 1.75rem;
background-size: 100% 100%;
background-image: url("data:image/svg+xml,%3Csvg width='40' height='36'
viewBox='0 0 40 36' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%2300B000'
fill-rule='evenodd'%3E%3Cpath d='...' stroke='%2300B000'
M31.4 17.476h2.564v-1.617H31.4z'/%3E%3C/g%3E%3C/svg%3E")
}
.svg{
width: 1.75rem;
height: 1.75rem;
background-size: 100% 100%;
background-image: url(../img/img.png);
background-image: url("data:image/svg+xml,%3Csvg width='40' height='36'
viewBox='0 0 40 36' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%2300B000'
fill-rule='evenodd'%3E%3Cpath d='...' stroke='%2300B000'
M31.4 17.476h2.564v-1.617H31.4z'/%3E%3C/g%3E%3C/svg%3E")
,none;
}
239个icon
490KB 76.5KB
fill
固定功能 (公积金 医院 水电)
特殊功能 (ETC 志愿者 大使馆)
用于需要缓存的需要换色的图片
用于不适合缓存及需要动画的图片
基本使用
参考project文件夹的demo
GUI版本暂时未合并,请给我三天时间:)
HTML
CSS
.svg{
background-image:url(../img/a.svg);
}