Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set equal font size in table cells for mobile device html pages

I got a problem with font rendering on mobile devices. I have a simple table width set fixed to 800 pixels, common size for todays mobiles.

Text in my cells all use the same html css makeup. The text in the first row show ok

But the next row is a problem it is split into two cells. The left cell is a picture and in the right cell there is some text. My problem is that most mobile web browsers scale down the font size in that cell.

To me it would be oké if that text would simply be spread over a bit more lines but that doesn't happen, they tend to keep as much lines similar as in a desktop browser view.

I've set the font size using pt px and no effect in the css file like

.DefaultFont 
{
font-family: 'Merriweather Sans', Arial,verdena,sans-serif;
font-size: 13pt;
font-style: normal;
color:#4e0203;
font-weight: 400;
}

used 13pt 13em and other methods etc nothing worked.

And for the html element used span and div and p and tried it inside td element, but again no effect.

PS I'm not looking for javascript tricks for scaling pages client side with device detection etc. As i simply use php to determine if its a desktop or a mobile device (which requires less code to be transmitted). I just need the code so that the font wont change as caused by a mobile web browser.

How do i stop those clients from rescaling parts of tables ?


SOLUTION The final solution that worked really nice was a combination of multiple people here.

  • Set table width's in %
  • Set font size in vw (which like % has also a 100 index), a low value like 2 or so.
  • Note vw is supported by lots more then just font size, also images.
  • include the meta tag it even worked without that after above, but to be on the safe side i recommend it.
like image 693
user613326 Avatar asked Sep 05 '14 11:09

user613326


People also ask

How do you change font size in a table cell in HTML?

To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size. HTML5 do not support the <font> tag, so the CSS style is used to add font size.

How do I change the font size in a table in pages?

To change all the text in the table, select the table; to change the text in specific cells, select the cells. In the Format sidebar, click the Text tab. Click the Style button, then use the text controls in the font section to change the font, size, colour or character style (such as bold or italic).

How do I Auto Adjust text size in HTML?

The font-size-adjust property gives you better control of the font size when the first selected font is not available. When a font is not available, the browser uses the second specified font. This could result in a big change for the font size. To prevent this, use the font-size-adjust property.


2 Answers

Have you tried Meta tags,to check if it works...

 <meta name="viewport" content="width=device-width, initial-scale=1">

This means that the browser will (probably) render the width of the page at the width of its own screen. So if that screen is 320px wide, the browser window will be 320px wide, rather than way zoomed out and showing 960px (or whatever that device does by default, in lieu of a responsive meta tag).

Check out,It may be helpful..

like image 195
Srinivas08 Avatar answered Oct 20 '22 11:10

Srinivas08


Maybe you should use viewport sized typography units for the font-size.

It can be used when you want to size thing through the viewport's (element container) width or height. Or both, for that matter. The possible values are:

vh - viewport's height
It sizes proportionaly to the container's height.

font-size: 2vh;

vw - viewport's width
It sizes proportionaly to the container's width.

font-size: 2vw;

vmin - viewport's minimum
It sizes proportionaly to the smaller between 'vh' and 'vw'.

 font-size: 2vmin;

vmax - viewport's maximum
It sizes proportionaly to the larger between 'vh' and 'vw'.

 font-size: 2vmax;

It surely can give you the looks that you want. Just find the current proportional value, and no matter the screen's size, it will fit!

W3 viewport relative length's docs

like image 40
LcSalazar Avatar answered Oct 20 '22 10:10

LcSalazar