android - 移动设备的 HTML 响应字体大小

标签 android ios html css responsive-design

我有一个在 Android 和 IOS 上运行的应用程序。
该应用程序有一些显示 HTML 的 WebView 组件
根据我的发现,有“em”和“viewport”单位 以及 css 中的“@media”。

我是 HTML5 和 CSS3 的新手,谁能给我看一个移动设备响应字体大小的例子。
对我来说最重要的是手机和平板电脑的字体大小不同, 也适用于不同屏幕尺寸的移动设备(纵向和横向)。

编辑:

WebView 组件不是全屏的,它们的大小与文本框一样,并且大小是动态的。

最佳答案

在媒体查询中使用

HTML

<p class="fonts">Administrator</p>

添加媒体查询

  @charset "utf-8";
    /* CSS Document */
    /* Smartphones (portrait and landscape) ----------- */
    @media only screen
    and (min-device-width : 320px)
    and (max-device-width : 480px) {
     .fonts
     {
      font-size: 75%;
     }    
    }
    /* Smartphones (landscape) ----------- */
    @media only screen
    and (min-width : 321px) {
     .fonts
     {
      font-size: 120%;
     }  
    }
    /* Smartphones (portrait) ----------- */
    @media only screen
    and (max-width : 320px) {
     .fonts
     {
      font-size: 120%;
     }  
    }
    /* iPads (portrait and landscape) ----------- */
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px) {
     .fonts
     {
      font-size: 120%;
     }    
    }
    /* iPads (landscape) ----------- */
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px)
    and (orientation : landscape) {
     .fonts
     {
      font-size: 150%;
     }    
    }
    /* iPads (portrait) ----------- */
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px)
    and (orientation : portrait) {

     .fonts
     {
      font-size: 120%;
     }  
    }
    /* Desktops and laptops ----------- */
    @media only screen
    and (min-width : 1224px) {
     .fonts
     {
      font-size: 156%;
     }    
    }
    /* Large screens ----------- */
    @media only screen
    and (min-width : 1824px) {
     .fonts
     {
      font-size: 200%;
     }    
    }
    /* iPhone 4 ----------- */
    @media
    only screen and (-webkit-min-device-pixel-ratio : 1.5),
    only screen and (min-device-pixel-ratio : 1.5) {
     .fonts
     {
      font-size: 190%;
     }    
    }

我使用 % 作为字体大小,这里只是字体大小的示例,尝试一下并添加您认为最好的 %

关于android - 移动设备的 HTML 响应字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17906057/

相关文章:

html - 如何防止 div 中断到下一行

javascript - 移动浏览器 : update element on back button

android - Google places API,获取用户地址

android - 使用 Android 创建高级 http 实体

ios - 我可以使用 ARKit 2 测量眼睛吗

ios - 如何在多个 View 上处理keyboardDidShow?

javascript - 如何在 DIV 控件之外处理 DIV 上的 onClick?

jquery - 如何根据jquery中出现的css类名添加类

javascript - React Native - 项目结构偏差差异

ios - SwiftUI View 不会在单独的 View 中更新