Genadinik
Genadinik

Reputation: 18639

Image looks terrible when viewed on a mobile browser, but perfectly fine on a web browser

I have this image:

http://www.problemio.com/img/app-store-icon.png

When I render it on a web browser, it looks fine, but if I look at it from my phone's browser, it looks really stretched.

Here is how I display it in a div:

<div style="float: left; width: 300px; padding-top: 15px;">
        <p><h3>Business Planning</h3></p>
        <div style="float: left;">
            <p><a href="https://apps.apple.com/us/app/business-plan-and-coach/id554845193">
                <img src="https://i.sstatic.net/SvB20.png" style="border: none;" alt="iPhone and iPad Business Plan App" /></a>
            </p>
        </div>
        <div style="float: left; padding-left: 10px;">
            <p>
            <a href="https://play.google.com/store/apps/details?id=business.premium">
            <img src="http://problemio.com/img/google-play-icon.png" style="border: none;" alt="Android Business Plan App" /></a>
            </p>
        </div>
        <div style="clear:both;"></div>
</div>

Any idea what may be causing the image to stretch when viewing on a mobile phone?

Upvotes: 2

Views: 821

Answers (2)

Telmo Marques
Telmo Marques

Reputation: 5106

Looking at the image element using Chrome's inspector:

<img src="http://www.problemio.com/img/app-store-icon.png" style="border: none; height: 99%; width: 99%;" alt="iPhone and iPad Business Plan App">

I have to say the problem resides in this styles:

height: 99%;
width: 99%;

Omit these, or set them to auto, if you don't want the image to change size.

On the other hand, if you do want to resize please see: Resize image proportionally with CSS?

Upvotes: 1

Giovanni Di Toro
Giovanni Di Toro

Reputation: 809

You'll have to use a responsive layout to resize the image according to the screen size. Example of responsive layout rule:

@media screen and (max-device-width: 480px) {
  .column {
    float: none;
  }
}

You can always search "responsive design" at any web search engine to get great references.

Upvotes: 1

Related Questions