1

I have two horrizontal tab images. I am moving my web application to display it in mobile.So I used responsive web design. I want the two horrizntal images to display inline. But when the screen width decreases, the second image is moving down. The image shrinks after moving down. I want the images shrink before moving down and it should not move down.CSS and HTML is given below.Please help.

.image-wrapper {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

<figure>
    <img class="image-wrapper" src="~/Images/Q.gif" />
    <img class="image-wrapper" src="~/Images/H.gif" />
    </figure>

2 Answers 2

1

You can achieve that using Media query. Try something like this:

@media (max-width : 320px) {

  .image-wrapper {
    width: 100%;
    height: auto;
    display: block;
  }
}
@media (min-width : 320px) {
  .image-wrapper {
    width: 50%;
    height: auto;
    display: inline-block;
  }
}

As seen from the code, the tipping point beyond which the images will flow one below the other is when the available width is less than 480px.

Sign up to request clarification or add additional context in comments.

6 Comments

I am using media queries only. The images is getting shrinked when i resize the window, that means,the css is working. But still I am not getting the result.
Till width of 480 it works already. I want it for a much smaller screen size around 320 for apple phones
@user2707092 so you wish to change into a single column layout when the width is 320px or less? Then just change the 480px in the sample code I posted to 320px. See my edited post.
I tired that already.But no luck. If I use only one image,it works fine.It shrinks,but for 2 images it goes down
I don't get it. Just fiddled it for you. Try re-sizing the Result container and notice the layout changing when the width falls below 320px. Just added float:left for the images to float side-by-side. You can also try reducing the width from 50% to 49.5%.
|
0

try using media queries, they will only apply to smaller screens

 @media only screen and (max-width : 760px) {
     img{
        width: 100%;
     }
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.