Search code examples
javascriptjquerymobileorientationimage-scaling

image height based on mobile orientation


I have a problem with a small mobile image gallery. When I change the orientation to portrait the images are too large to be displayed on the screen.

Is it possible with some javascript to make images fit the screen when the orientation changes to portrait?
In landscape mode, everything looks fine.


Solution

  • Try this:

    @media screen and (orientation:portrait) {
        //your css code goes here
    }
    
    @media screen and (orientation:landscape) {
        //your css code goes here
    }