0Logo HTML5images de fond sensibles pour les sites Web

J'ai récemment été mise à jour mon site Web et le serveur Web et l'ajout d'un nouveau site (LoveCrete.org). Je voulais avoir une image de fond sur LoveCrete et réalisé que bien sûr 1 ne convient pas à tous les écrans. Here is a sum­mary of what my think­ing was and what I did to cater for the numer­ous screen sizes and orientations.

Quelle orientation

I star­ted by mak­ing myself a little table of all the com­mon res­ol­u­tions used on PC and tab­lets (in hori­zont­al ori­ent­a­tion). I decided to focus on this because most images are avail­able in land­scape so this is a sens­ible place to start.

I decided that I would place images cent­rally on the page and let the edges be lost off the edge of the screen in some instances. When a phone is used in por­trait ori­ent­a­tion it will load the image based on height (pas de largeur) et va perdre beaucoup à la fois bord de l'image. Doing it any oth­er way would mean need­ing images cropped to a totally dif­fer­ent shape or hav­ing a land­scape image “tile” on a tall screen, qui est pas souhaitable.

The ratios of the max­im­um size image to make in each group were all around 1.6 with a few a bit high­er. To keep things sim­pler I decided to use a ratio of 16:10 pour toutes les images et est venu avec des tailles pour faire en conséquence.

This means in most cases the image will not be a per­fect fit to the screen size, but all screens will get some­thing very close and no screen will end up with some­thing too small. Cela signifie aussi une image source peut être recadrée 16:10 once and then mul­tiple sizes eas­ily created

groupes de résolution de paysage commun

la tailleLargeurImage pourCom­ments
4:316:1016:9
2160288038402400×38404k UHD
1600
1536
1440
-
2048
1920
2560
-
-
-
-
2560
1600×2560
1200
1080
1050
1600
1440
1400
1920
-
1680
-
1920
-
1200×1920Full HD 1080p
960
900
1280
1200
1536
1440
-
1600
1000×1600
800
768
720
-
1024
960
1280
-
-
-
-
1280
800× 1280720p
600
576
800
768
960
-
-
1024
640×1024
480640768480×768

As you can see I have grouped quite a few res­ol­u­tions and will then make 1 image that will cov­er all heights up to the largest height in that group. I will make sure the image is also wide enough for the max­im­um width such a height might be paired with on a nor­mal screen. I haven’t taken account of unusu­al con­fig­ur­a­tions like 21:9 mon­it­ors or mul­tiple screens — there has to be a lim­it somewhere!

Car CSS uses the view­port or browser size and not the screen size land­scape screens need to use width rather than height — as on most sys­tems the top and bot­tom lose space to title bars etc whilst the width is usu­ally max­im­ised. Cependant, for por­trait dis­plays it is bet­ter to use the height prop­erty. Cela peut se faire en CSS can identi­fy the screen orientation

le CSS utilisé semble alors comme suit

Nous avons trouvé cet utile? S'il vous plaît ne laissez-nous savoir en laissant tomber un commentaire ci-dessous. Si vous souhaitez vous abonner s'il vous plaît utiliser le lien d'abonnement dans le menu en haut à droite. Vous pouvez également partager avec vos amis en utilisant les liens sociaux ci-dessous. À votre santé.

Laisser un commentaire