I am putting together an HTML page to be viewed in both mobile phones and PC/Mac. In the text, I sometimes have inline images:
<p>to do that, then press on button <img src="button.png" /> for 2 seconds</p>
My fonts are sized in em or % so it is readable on both low res-phones and high-res phones. The issue is that my buttons (usually 32px high images) appear so tiny on high-res phones.
How do I adjust the image size? Preferably pure CSS, but JS is still OK.
If you set the size of your font in the <p> tag, you should just be able to use height: 1em; on p img to set the image's height to that of the font. And if you want it to be double the size of the font, you'd just set the height of the image to 2em.
If you set the size of your font in the <p>
tag, you should just be able to use height: 1em;
on p img
to set the image's height to that of the font.
Here's a jsfiddle to show what I mean:
body { font-size: 62.5%; /*sets 1em to 10px for convenience*/ } p { font-size: 3em; } p img { height: 1em; width: auto; }
<p>Hello world! <img src="http://images.wikia.com/dragonvale/images/e/e8/Space_invader.jpg"></p>
And if you want it to be double the size of the font, you'd just set the height of the image to 2em.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With