HTML5之圖片在Retina屏的常用幾種處理方式
阿新 • • 發佈:2018-02-13
tin screen width html5 bar color pan led image
- Media Queries
使用css3的媒體查詢實現高清屏的圖片處理。@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min-device-pixel-ratio: 1.5) { .logo { background-image: url(‘img/[email protected]‘)
sass的mixin
//-----------------------------------Retina圖片----------------------------------------- @mixin image-2x($image, $width, $height) { @media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6/2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx) {
- retina.js下載 免費CND GitHub
- CSS4的image-set屬性
.test { background-image: url(‘img/logo.jpg‘); background-image: -webkit-image-set(url(‘img/logo.jpg‘) 1x,url(‘img/[email protected]‘) 2x)
- HTML5 picture Element
<picture> <source media="(min-width: 1024px)" srcset="foo-large.jpg 1024w, foo-medium.jpg 640w, foo-small.jpg 320w" sizes="50vw" /> <source srcset="[email protected] 2x, foo.jpg 1x" /> <img src="foo.jpg" alt="Bar" /> </picture>
- 服務端處理 Retina Images github
使用方法
HTML5之圖片在Retina屏的常用幾種處理方式