Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
css px单元如何映射到实际设备像素?_Css - Fatal编程技术网

css px单元如何映射到实际设备像素?

css px单元如何映射到实际设备像素?,css,Css,下面是html代码 <html> <head> <style type="text/css"> .my { border: 2px solid; width: 414px; height: 500px; } .right { text-align: right } </style> </head> <body> <h2&g

下面是html代码

<html>

<head>
  <style type="text/css">
    .my {
      border: 2px solid;
      width: 414px;
      height: 500px;
    }

    .right {
      text-align: right
    }
  </style>
</head>

<body>
  <h2>this is the ...</h2>

  <div class="my">abc</div>
  <div class="right">this is the right</div>
</body>

</html>

.我的{
边框:2倍实心;
宽度:414px;
高度:500px;
}
.对{
文本对齐:右对齐
}
这是。。。
abc
这是正确的
你可以看到414像素的div在那里

我知道devicePixelRatio是3,所以实际的像素宽度大约是414*3像素。但当我在css中将宽度设置为414像素时,为什么它占据了大约2/5的宽度?css像素如何映射到实际像素

另附一份。
为什么我需要设置960px来填充iphone 6plus的宽度?

您必须使用
视口
metatag
来控制移动设备上的布局

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

我怀疑你错过了这个元标记

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

据我所知,您需要使用viewport meta标记

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


我认为这与像素缩放关系不大,而与视口缩放关系更大。默认情况下,iOS上的Safari(我不知道其他版本)倾向于缩小页面,以适应传统桌面站点太宽而无法容纳更小的屏幕。如果你设置
,我同意@BoltClock。使用
meta
标记。你为什么会怀疑这一点?看起来这正是他所缺少的。@BhuwanBhatt不幸的是,我错过了答案中的meta标签。我现在编辑了这篇文章。