Retina Monitor’s Web Image Solution
什麼是Retina螢幕
今天來談談網頁圖片在視網膜(Retina)螢幕的顯示議題,首先必須來談談什麼是視網膜螢幕,其實他就是一種能在單位尺寸內顯示更多像素點的螢幕,且已經達到視網膜能辨識的極限,視網膜螢幕是由蘋果公司提出,賈伯斯在2010年iPhone 4的發表會中提到:「當你所拿的東西距離你10-12英寸(約25-30厘米)時,它的解析度只要達到300ppi這個『神奇數字』(每英寸300個像素點)以上,你的視網膜就無法分辨出像素點了。」
所以簡言之,視網膜螢幕比較一般非視網膜螢幕的不同處在於,能在同樣的範圍顯示更多的像素點,也就是PPI(Pixels Per Inch)比較高的螢幕,可參考下圖所示:
可以看到圖左在單位尺寸內顯示的像素點較少,圖右則能以更多的像素去呈現,在肉眼上就會覺得圖右會比較細緻。
接下來談談網頁圖片與視網膜螢幕之間的關係,先來看看同樣一張圖片在不同螢幕上顯示的效果。
當然在美觀的立場下,我們不會希望發生這樣的視覺差異,那網頁上要如何設置才可以做到讓圖形在視網膜螢幕下也能正常的顯示呢?以下提出一些解決方案:
方案1. 透過CSS針對不同的DPR (Device Pixel Ratio)設計顯示圖片
大家如果想知道自己螢幕的DPR,可以在Chrome的主控台輸入“window.devicePixelRatio”,就可以得知目前Chrome所在螢幕的DPR值。
可以觀察出來在兩個螢幕的DRP值是不同的,而透過CSS的樣式,可以針對這兩個不同的DPR設定顯示方式,可以參考下面的做法:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .logo{ width: 190px; height: 190px; background-image: url("atd-icon.jpg"); background-size: contain; } @media (-webkit-min-device-pixel-ratio: 2){ .logo{ background-image: url("atd-icon@2x.jpg"); } } </style> </head> <body> <div class="logo"></div> </body> </html> <script> </script>
這邊必須針對圖檔尺寸做個說明,其中atd-icon.jpg為190 x 190,而atd-icon@2x.jpg為380 x 380。
@media (-webkit-min-device-pixel-ratio: 2)的部分是在DPR兩倍下的Media Query。
透過這樣的方式去設定,當DPR為2的時候,螢幕上的圖片改變為atd-icon_2.jpg,剛好能夠滿足在兩倍像素狀況下的顯示需求,當然以此類推,也能去設定三倍或更高倍數下的顯示圖片。
方案二. 透過img標籤的srcset屬性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <img src="atdIcon.jpg" srcset="atd-icon@2x.jpg x2"> </body> </html> <script> </script>
其中srcset=”atd-icon@2x.jpg 2x”表示在DPR等於2的時候要去呈現的圖片。
以上兩個方法都可以解決圖片在Retina螢幕上面顯示的問題,但也要稍微注意一下支援程度:
可以看到在IE都是無法支援的狀態,但從Edge後就開始支援,當然也可以想想目前擁有Retina螢幕的使用者,用的瀏覽器都會是哪些?說不定你不會太在乎上面那兩張圖紅色的部分。
但若是一定要有IE瀏覽器的支援,大家應該也能從上述的文章了解,我們可以透過window.devicePixelRatio的數值自行寫script進行判斷,然後再給出適合DPR的圖片,不過這邊另外推薦一個JS Library可以協助你進行這方面的判斷。
方案三. 透過Retina.js輔助進行判斷
首先到Retina.js的網站下載他們所提供的js檔,接下來至網頁引入該JS,其實網站上也有詳細的使用方法,另外檔案大小僅有約4KB並不算很大,可以參考下面的Sample Code。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="retina.min.js"></script> </head> <body> <img src="atd-icon.jpg" /> </body> </html>
可以看到在img標籤中僅使用了原始大小的atd-icon.jpg,但因為有引入retina.min.js,他會在螢幕DPR兩倍時,自動去搜尋符合倍率下的圖片,但要記得如果不加其他屬性去設定兩倍圖片的檔名,檔名就必須按照內建的規則,也就是atd-icon@2x.jpg,當然3x也依然支援,可以到官網看一下他的使用方式,但若是使用CSS設定的背景,依然沒辦法透過retina.js達到支援IE的效果。
以上三個方法提供目前在設計網頁時,對於Retina螢幕支援的做法,若在不考慮IE瀏覽器的情況下,其實方法1+方法2就已經可以解決所有情況,但若要支援IE則可以參考方法三的做法,也歡迎大家有問題可以留言進行討論。
方案四. 使用SVG圖檔
過往我們在網頁中使用的圖片僅有GIF、PNG、JPG這三種點陣圖格式,所以在高解析度(Retina)的螢幕中,我們需要輸入不同Size的圖片,來補足像素點不足的問題,現在有了另外一種解法“SVG”圖檔。
大家可以把SVG視為一種可以放在網頁上的向量圖檔,也就是說我們以前透過Illustrator或其他向量繪圖軟體(也包含Photoshop中向量工具)繪製出來的向量圖,本身放大就不會失真,但因為要放在網頁上,我們把它轉換成了前述的三種點陣格式,才導致圖檔放大後的失真,而SVG就是保留圖片原來的向量屬性,簡言之,就是把向量圖檔放在網頁上的意思。
感覺這個解決方案應該會比前幾項方便,但也有他必須要注意的地方:
- 在SVG檔案中匯入的點陣圖,在儲存成SVG時並不會被向量化,例如上圖中間的ASUS Design Logo就是匯入的點陣圖(放大後還是會模糊)。
- SVG字型可能會遺失,所以需要使用網路字型或是將文字轉成外框或形狀之後再轉存成SVG。
http://icc.cku.ac.kr/bbs/board.php?bo_table=free&wr_id=107276
https://writeablog.net/tenoreditor8/environment-change-and-precisely-what-to-complete-about-this
The bookmaker also takes bets on tv exhibits like Psychic Challenge, What? Pay a visit to the brand’s website to look into Melbet minimum deposit India. Melbet pays also a special attention to India residents and offers an exceptional welcome bonus of 9750 Indian rupees. Melbet Promo Code India Copy the About coupon code to get the first deposit bonus. Melbet is a popular betting site among Indians when it comes to making bets on Cricket or other sports, and they offer 100% bonus up to ?10400 for every India. Players can also enjoy the website in many other countries like Ghan best promo code Melbet
Melbet welcomes new players to a variety of bonuses. Melbet for today are bonus opportunities that the bookmaker itself gives. Today, many bookmakers offer such bonuses both for first-time registered users and for those who have been betting on sports for a long time. MelBet Promo Code Free – welcome bonus worth 130% up to €/$130. Welcome bonuses, free spins and freebets are equally available to all users, regardless of which gadget they use for the registration procedure or betting. Melbet often offers many exciting bonuses and offers that will make your time on the site more exciting and rewarding. Melbet promo code Guyana
Melbet welcomes new players to a variety of bonuses. Melbet for today are bonus opportunities that the bookmaker itself gives. Today, many bookmakers offer such bonuses both for first-time registered users and for those who have been betting on sports for a long time. MelBet Promo Code Free – welcome bonus worth 130% up to €/$130. Welcome bonuses, free spins and freebets are equally available to all users, regardless of which gadget they use for the registration procedure or betting. Melbet often offers many exciting bonuses and offers that will make your time on the site more exciting and rewarding. promo code Melbet
Melbet is among the top operators offering a variety of sporting events and eSports. Claim top bonuses using our exclusive MelBet Promo Code and Welcome Bonuses, this is the best chance to join one of the most popular betting platforms and start winning with free bets and bonus money. Welcome bonuses and special promo codes will be perfect starters to help you enjoy our betting site with bonus money and free bets. Read the article to learn how to use one of the best betting bonus offers in India. Melbet promo code
Melbet is among the top operators offering a variety of sporting events and eSports. Claim top bonuses using our exclusive MelBet Promo Code and Welcome Bonuses, this is the best chance to join one of the most popular betting platforms and start winning with free bets and bonus money. Welcome bonuses and special promo codes will be perfect starters to help you enjoy our betting site with bonus money and free bets. Read the article to learn how to use one of the best betting bonus offers in India. Melbet promo code Singapore
sildenafil 50mg ca fildena online rhinocort generic
sildenafil 50mg pill fildena 100mg over the counter buy budesonide sale
https://www.lsdporn.com/
Add a Melbet promo code if you want to use it. Remember the username and the password that appear on the screen. Allow phone number verification for additional security of your account. Although there isn’t a Melbet registration by phone number, players can get a download link for an app sent to them via SMS. Melbet Promo Code India already using the company to beat its competitors and attract more neutral punters. Anyone can get lost and lose its funding after unsuccessfully Paris. Just choose a trusted bookmaker – and you can rely on different types of rewards, so that you can earn even more profit with your paris.
promo code Melbet
Melbet welcomes new players to a variety of bonuses. Melbet for today are bonus opportunities that the bookmaker itself gives. Today, many bookmakers offer such bonuses both for first-time registered users and for those who have been betting on sports for a long time. MelBet Promo Code Free – welcome bonus worth 130% up to €/$130. Welcome bonuses, free spins and freebets are equally available to all users, regardless of which gadget they use for the registration procedure or betting. Melbet often offers many exciting bonuses and offers that will make your time on the site more exciting and rewarding. promo code for hbet
The Melbet bookmaker provides bonuses and promo codes, every bettor can receive bonuses. Get 130% off the current promo code for Melbet for free. New registration coupons every hour on the website. Melbet Promo Code 130 $ Fun layout for Android or iPhone applications. Since the promo code must be used upon sign-up, it can be claimed by new players registering with Melbet. Regarding the promotion, other offers from this bookmaker, it is proposed to users in adults. Registering with Melbet is easy to do in Nigeria with a Melbet promo code Nigeria players can use. Melbet promo code Sierra Leone
Melbet welcomes new players with a variety of bonuses. To register an account at Melbet, a player needs to be aged 18 years and above.While there exist tons of bonuses including periodic ones, these are the popular bonuses you can claim via our Melbet Promo Code to access all the 40+ selections made available to players. Melbet sportsbook offers a diverse range of sports selections to players which is the standout factor. The betting opportunities have been numerous and aside from the sports markets, players can also enjoy highly competitive odds with minimal betting margins. Melbet promo code 2023
The user needs to be a new registrant and shouldn’t have done any deposits before that deposit. If you are satisfied with the requirements then you are obviously free from the Melbet Promo Code for Indian give you access to the bookmaker’s bonus program. Melbet is for players who like to bet on different sports, love to try out new things and enjoy regular promotions that give them more cash to play with. There is a huge variety of different promotions here on Melbet and that’s never a bad thing! Signup on Melbet is easy – in less than a minute, you can have a Melbet account up and running! Melbet promo code Cameroon
https://www.pornojaba.com/
https://www.pornoytka.com/
https://pornoskill.com/
pene de jГіvenes cialis 5 mg significado de disfuncional
Many users, after reading the bookmaker’s bonus offers, want to know how to get melbet promo code. Melbet allows its customers to receive exclusive bonuses if they enter a promo code upon registration. In this article, we will look at what a Melbet Promo Code India is, how to use it, and what additional bonuses it gives. There is an opportunity to get the melbet bonus code from the site partners, on thematic forums. Also, melbet bonus is distributed by the casino administration during special events. The opportunity to make good money on such promotions is often mentioned in reviews of Melbet online casinos.
Melbet promo code From Sudan
crema para la disfuncion erectil comprar cialis ereccion de un hombre al dia
https://canadian-pharmacy.shop/# online canadian pharmacy reviews
order sildenafil 50mg without prescription brand nolvadex 20mg purchase rhinocort pills
Lorsque vous vous dirigez vers le casino 1XBET, il y a un code promotionnel qui doit etre utilise pour obtenir l’offre de bienvenue jusqu’a 1500 € avec 150 tours gratuits egalement offerts. Code promotionnel gratuit 1xBet pour aujourd’hui Inscrivez-vous pour un compte gratuit aujourd’hui en utilisant ce lien et profitez de votre bonus 1XBET. Ou puis-je obtenir un code promotionnel de pari gratuit 1xBet et vais-je certainement faire confiance aux codes numeriques qui peuvent etre accessibles au public sur le net ? Mieux encore, vous pouvez acceder a la diffusion en direct de vos sports preferes, notamment le cricket et le football, entre autres sports, lors de votre inscription a 1xBet sur cette page. Cela vous permettra de recevoir leur excellent bonus de bienvenue jusqu’a 130 $
Code Promo 1xBet Mali
https://somanyporn.com/
Entrez notre code promo exclusif pour obtenir un bonus de 130 $ sur le site 1xbet. Offre limitee. Meilleure promotion garantie Code promotionnel Davido pour 1xBet Il suffit de s’inscrire pour devenir millionnaire du jour au lendemain. lors de l’inscription et obtenez un bonus de bienvenue Partenaire de pari officiel de l’ambassadeur de la marque du FC Barcelone. Le code promo chez le bookmaker 1xbet est le mot de code pour activer le bonus d’inscription 1xbet pour les nouveaux utilisateurs. Creez un compte gratuit actuellement en utilisant ce lien hypertexte et profitez de votre bonus 1XBET, avec notre code promotionnel 1XBET.
code promo 1xbet valide
Termes et conditions du bonus de bienvenue 1xBet Offre d’inscription 1xbet ? Code bonus actuel ? Toujours a jour ? Tout ce que vous devez savoir ? Reclamez votre code promotionnel de bienvenue 1xbet maintenant ! 1xBet Promo Code Free Bet et encaissez votre premiere recompense bonus, qui est leur enorme recompense de nouveau joueur. Marches des paris et cotes — Voici ce que vous pouvez vous attendre a obtenir avec notre code promotionnel 1XBET : Assurez-vous de lire le code promotionnel des termes et conditions du bonus 1xbet. Rendez-vous sur 1xbet via ce lien afin de recevoir le meilleur bonus de bienvenue disponible. Utilisez ce code lorsque vous rejoignez 1xBet.com pour obtenir un bonus supplementaire de 30 % sur votre premier depot.
Code Promo 1xBetGabon
impotencia sexuales cialis que es la erecciГіn
Nous nous sommes associes au bookmaker 1XBet pour vous offrir les meilleurs bonus possibles. Le bonus de bienvenue sportif 1xBet est un bonus de depot. La plupart des joueurs obtiennent 100 % jusqu’a 100 $. Cependant, si vous profitez de notre code promotionnel 1xBet unique dans le formulaire d’inscription et profitez de votre bonus de bienvenue EXCLUSIF de 100 % jusqu’a 130 €/$ ! Tout est simple. Le 1xBet vous offre de meilleures recompenses. Lorsque vous effectuez votre depot initial, le bonus standard 1xBet est un bonus de depot correspondant a 100 %. Vous pouvez l’utiliser sur toutes les rubriques : sports, live, casino, jeux, sports virtuels, bingo, poker.
Code Promo 1xBet Rwanda