Skip to main content

responsive site: img style

Q: For websites with responsive designs/templates, how do you keep small images from being distorted (in other words, enlarged and pixelated = ugly) on smartphone screens?

A: The simple solution is to set the width within the IMG style tag.

For example: Your image is 150px-wide. To lock it at 150px (the upper limit should be the image's actual width so it will still look nice), use:

<img alt="#" src="#" style="width: 150px;">

Up Next: How to center (awkward... verb) an image when the <div> or <p> elements don't work. These alignment tips from w3.org clearly explains it all. It says CSS but we can use the style code within the body's html source which sort of trumps the CSS (if you're using a template) so we can still make style changes per page. OK, here's the fix:

<img src="#" alt="#" style="display:block; margin-left:auto; margin-right:auto; width:#px;">

On a responsive web design, if the image is small (ex. for buttons, badges, etc.), specify width so it doesn't get distorted on smaller screens.

For reference, W3C on the IMG Element (HTML5). Also,

The img element is a void element. An img element must have a start tag but must not have an end tag.

Comments

Popular posts from this blog

Gold ring size 6 for ref

A “pawnable” 0.69g 18k Saudi yellow gold ring (photo sent by the Shopee seller). My ring size is 6... in case I forget. Another buyer left a review that when they took it to Cebuana, they received an appraised value of P1,800 or ~50% of the retail price. Gold 18k market value is ~P3,400 per gram as of today (Sept. 11,2024). But for serious assets = gold bars are preferred over jewelry.  Actual ring I received ✨ Pretty small hearts design and stamped Au750 / 6. The diamond cuts make it sparkle. It looks very nice when worn. 

December in food pics 2023

  Chicken Nuggets (Purefoods Chicken Breast Nuggets) Yum with BBQ sause. Sliced mango yung nasa taas, masarap din, matamis. Homemade Baked Macaroni Ordered from a neighbor for noche buena. It has beef, mushrooms and bechamel sauce. Still yum. Second year in a row na since  2022 noche buena macaroni . Pork tocino and scrambled egg (Pampanga's Best Original Tocino) with suka, syempre. Dry yung eggs huhu. Sinangag sana yung rice pero bagong saing kasi. Dapat sa fried rice yung day-old na maalsa para buhaghag. Speaking of... tagalog ako pero yung term na "maalsa" sa bigas, recently ko lang naintindihan 😁 

Panda Express Everyday Bowl PH

Panda Express Everyday Bowl Delivery via Food Panda Panda Express PH:  "Everyday Bowl" 1 Entrée + 1 Side Orange Chicken + Fried Rice =  ₱  239.00  + rider's tip - discount voucher  Panda Express' orange chicken is already full of salty, sweet flavor so this many pieces is good for two if the other person is not very hungry. Bought their "Everyday Bowl" just to try since I was craving fried rice. Usually, I get the "classic plate" with 2 entrees + 1 side of mixed veggies.