简体   繁体   English

如何在手机上更改字体大小?

[英]How to change font size on Mobile?

I currently have this html code that shows on desktop.我目前有这个在桌面上显示的 html 代码。 How do I can add the specific mobile code so I can reduce the font size to 35 px on mobile?如何添加特定的移动代码,以便在移动设备上将字体大小减小到 35 像素?

 <div style="float: left; width: 100%;" class="sapMktBlock"> <h3 class="mobileheader" style="margin: 10px 0px 30px; line-height: 50px; letter-spacing: normal; font-family: Baskerville; font-size: 50px; font-style: normal; font-weight: normal; display: block; color: #000000;important: text-align; center:">Looks Like Something <br />Caught Your Eye</h3> <table class="deviceWidth" style="mso-table-lspace; 0pt: mso-table-rspace; 0pt: mso-line-height-rule; exactly: border-collapse; collapse:important; margin: 0 auto; max-width: 600px;" border="0" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr></tr> </tbody> </table> </div>

You can use Media Queries like this.您可以像这样使用媒体查询。

Mobile Viewport sizes varies from 360 x 740, where 360 is width and 740 is height移动视口大小从 360 x 740 不等,其中 360 是宽度,740 是高度

@media (max-width:360px){
    // Write your code Here, for example
    .my-text{
        font-size:12px;
        color : red;    
    }
}

Here is a very simple example of using css units vh and vw :这是一个使用css单位vhvw的非常简单的示例:

 <h1 style="font-size: 7vh;">Becomes bigger on mobile devices</h1> <h1 style="font-size: 7vw;">Becomes smaller on mobile devices</h1>

Media queries are your best option for this, just do what ZeevhY Org.媒体查询是您最好的选择,只需执行 ZeevhY Org 的操作即可。 posted张贴

Place it at the bottom of your CSS file or bottom of you script tag将其放在 CSS 文件的底部或脚本标签的底部

@media (max-width:the max pixel value you want it to apply at(you can also do min)){
    // Write your code Here, for example
    .my-text{
        font-size:12px;
        color : red;    
    }
}

note: if you have multiple overlapping media queries you might need to use.important on some CSS tags so they apply.注意:如果您有多个重叠的媒体查询,您可能需要在某些 CSS 标签上使用.important,以便它们适用。

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

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