html - Change order of images when switching to landscape -


currently working on mobile website client can't following work. homepage of mobile site gets divided 2 large images users make choice. portrait mode works stacking images on homepage following code.

<p><a href="/female"><img alt="" src="image1.jpg" style="width: 100%; height: 51%; position: absolute; margin-top:0; left:0; right:0;" /></a> <a href="/male"><img alt="" src="image2.jpg" style="width: 100%; height: 49%; position: absolute; bottom:0; left:0; right:0;" /></a></p> 

this works fine on devices whilst in portrait mode, problem these devices used in portrait mode, images stretched much. of course because of 100% width.

in ideal situation; when switching landscape 2 entirely different images aren't on top of 1 side side.

example;

     ___                 ________     | 1 |               | 1   2  |     |_2_|               |________| portrait mode         landscape mode 

hope drawing makes sense.

you can use @media rule querying property orientation, rule applied when orientation portrait (the default landscape):

img {   width: 100%;   height:100%;      box-sizing:border-box;   border:1px solid green; } {   display:inline-block;       width:50%;         } @media screen , (orientation:portrait) {   {      display:block;              width:100%;   } } 

here working fiddle. test fiddle, have try resizing display window changes landscape portrait or vice-versa.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -