Being a designer today, one of the biggest obstacles in my life today is placing an image on a web page that fits all browsers on all devices. To fit one image, I tried to create a code like the one below and check the height and make sure that the image fits and the image is in the middle of the screen. All I want to do is place a 600x894 image in the middle of the screen, regardless of device or browser. If the screen size is smaller, then the image should be smaller. What is the best way to do this?
img {position:absolute;left:50%;top:50%;display:block;} @media only screen and (max-height : 600px) {img{width: 389px;height: 580px;margin-left: -194px;margin-top: -290px}} @media only screen and (max-height : 700px) {img{width: 456px;height: 680px;margin-left: -228px;margin-top: -340px}} @media only screen and (max-height : 800px) {img{width: 524px;height: 780px;margin-left: -262px;margin-top: -390px}} @media only screen and (max-height : 900px) {img{width: 591px;height: 880px;margin-left: -295px;margin-top: -440px}}
html css html5
CTU Chicago
source share