简体   繁体   English

手机字体大小问题

[英]Problems with font sizes for mobile

I am making a responsive site and I can't figure out how to solve the problem with mobile devices with high dpi. 我正在建立一个响应迅速的网站,但我不知道如何解决dpi高的移动设备的问题。 I have set my h2 to 2em and my p to 1 em, so the h2 should be twice the size of the p, right? 我将h2设置为2em,将p设置为1 em,所以h2应该是p的两倍,对吗? Well they're pretty much the same size when I'm in portrait mode on my Galaxy S4. 好吧,当我在Galaxy S4上处于人像模式时,它们的尺寸几乎相同。 It looks better in landscape for some reason. 由于某种原因,它在景观中看起来更好。 I also noticed by using a javascript that shows the width of the viewport that the galaxy s4 is always 980px wide, both in landscape and in portrait, isn't that weird? 我还注意到,通过使用显示视口宽度的javascript,无论横向还是纵向,s4星系s4始终为980px宽,这不是很奇怪吗?

I am using 我在用

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

But I'm not sure it's working properly.. since the viewport is 980px wide on my S4 in portrait, the breakpoints one would normally use for mobile doesnt work. 但是我不确定它是否能正常工作。.由于在我的S4肖像上视口是980px宽,因此通常用于移动设备的断点将不起作用。 My phone thinks it's a tablet! 我的手机认为它是平板电脑!

I have googled a lot but nothing seems to be working. 我在Google上搜索了很多,但似乎没有任何效果。 Does anyone have any tips or know where I'm messing up? 有人有任何提示或知道我在哪里搞砸吗?

Thanks! 谢谢!

Edit: I tried 编辑:我试过

@media all and (min--moz-device-pixel-ratio: 1.5),
    (-webkit-min-device-pixel-ratio: 1.5),
    (min-device-pixel-ratio: 1.5)

which worked, I can now set a seperate media query for all devices with higher pixel ratios. 在有效的情况下,我现在可以为所有像素比率更高的设备设置单独的媒体查询。 But the font size of my h2's is still weird. 但是我的h2的字体大小仍然很奇怪。 I have to set it to 4em to make the h2 approximately twice the size of the 1em p in portrait, but in landscape it is much bigger. 我必须将其设置为4em才能使h2大约是肖像中1em p的两倍,但在风景中则要大得多。 what's with the font sizes in portrait mode on my phone?? 我的手机在纵向模式下的字体大小是多少? :S :S

Not sure it'll help but I usually use: 不确定会有所帮助,但我通常使用:

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

also remember that em's are relative so depending on where you set the actual font size, em's take on different values (so if your body is set to font-size: 14px your h2 would be 28px font, but if your h2 is in a container which has font-size: 16px the h2 would be 32px) 还请记住em是相对的,因此取决于您在何处设置实际字体大小,em会采用不同的值(因此,如果将body设置为font-size:14px,则h2将为28px字体,但是如果h2在容器中字体大小:16px,h2为32px)

Added: 添加:

Dunno about using em's for breakpoints...I've always used fixed pixels. Dunno关于使用em作为断点...我一直使用固定像素。 And make sure you include device-width. 并确保您包括设备宽度。 EG for tablet-specific styles: 平板电脑专用样式的EG:

@media only screen
and (max-device-width: 979px),
(max-width: 979px) {
body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM