Bootstrap 移动的上的引导字体缩放太小

3xiyfsfu  于 2022-12-16  发布在  Bootstrap
关注(0)|答案(6)|浏览(163)

我花了很多时间在Foundation上,而花在Bootstrap上的时间却很少。我不明白Bootstrap的响应性有什么问题,因为它似乎只在Foundation上起作用。问题是,虽然网格响应性按预期工作,但我的字体被缩放得太小,以至于在移动的上几乎难以辨认。请注意,在下面的示例中,我将字体大小设置为14px。但在移动的上,这变得非常微小。你可以通过点击Chrome开发工具中的移动按钮来看到这一点。
用html来重现这个很简单,下面是一个jsbin:http://jsbin.com/lumepumufu/1/
下面是html:

<html>
  <head>
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  </head>
  <body style="font-size:14px">
    <div class="container">
      <div class="row">
        <div class="col-lg-4">col-lg-4</div>
        <div class="col-lg-4">col-lg-4</div>
        <div class="col-lg-4">col-lg-4</div>
      </div>
    </div>
  </body>
</html>
olmpazwi

olmpazwi1#

Bootstrap是移动的优先的。移动优先样式可以在整个库中找到,而不是在单独的文件中。
为了确保正确的渲染和触摸缩放,请将viewport meta标签添加到head中

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

hs1rzwqc2#

您应该始终从模板开始,例如“基本模板”(http://getbootstrap.com/getting-started/#template)。这可以正常工作:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
        <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body style="font-size:14px">
    <div class="container">
      <div class="row">
        <div class="col-lg-4">col-lg-4</div>
        <div class="col-lg-4">col-lg-4</div>
        <div class="col-lg-4">col-lg-4</div>
      </div>
    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
  </body>
</html>

这可能看起来像很多“cruft”,但一切都是有原因的。

uajslkp6

uajslkp63#

如果您运行的是Rails应用程序,可以尝试gem rails_layout

t3irkdon

t3irkdon4#

我遇到了小字体和小导航栏的问题,我的问题是在css中设置导航栏宽度,使用最大宽度而不是仅仅宽度解决了我的缩放问题

0kjbasz6

0kjbasz65#

使用“rem”代替px;(像素);例如.myclass {字体大小:1雷姆; }

umuewwlo

umuewwlo6#

我遇到了这个问题,我的问题最终是我正在使用的代码格式化程序。它用“/"结束标记,这导致我的程序不使用标记。具体来说:

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

相关问题