简体   繁体   中英

Responsive Design: Images in portrait / landscape mode

So I'm making my theme user-friendly for cellphones, but I really want to make a special thing about images. If the images is landscape, I want the width to be smaller than it would if the images were portrait... And I mean it is possible to do this by the "@media-screen max-width/max-height" thing in css... Am I on the right track? Or do I have to throw in a JS there?

This should be what your looking for. It uses a percentage width and an auto height to make sure all the photos have the same width but the height adjusts to make sure the image doesn't become distorted. The phone tag in the css is only to simulate a phone screen. Hope it helps :D

http://jsfiddle.net/LdeGJ/

img{
width:90%;
height:auto;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM