nativescript CSS测量单位

krv*_*krv 5 css nativescript

我一直在与nativescript一起玩,我看到它为我们提供了使用CSS设置样式的元素。

但是,在文档http://docs.nativescript.org/ui/styling.html中,我没有看到有关CSS的度量单位的任何提及。

这有效

.title {
    font-size: 30;
    horizontal-align: center;
    margin: 20;
}
Run Code Online (Sandbox Code Playgroud)

这不起作用

.title {
    font-size: 30;
    horizontal-align: center;
    margin: 20px;
}
Run Code Online (Sandbox Code Playgroud)

请注意,在第二个示例中,边距为20px。

所以我的问题是,当涉及CSS时,nativescript使用哪个单元?

Amj*_*ous 5

如果有人在 2019 年及以后遇到过这个问题,文档会指定 Nativescript 中的测量单位。

“NativeScript 支持DIP(设备独立像素)像素(通过后缀 px)和百分比(部分支持宽度、高度和边距)作为测量单位。

NativeScript推荐的测量单位是DIP。所有可测量的属性(例如宽度、高度、边距、填充、边框宽度等)都支持设备独立像素。字体大小始终以 DIP 为单位进行测量。”

链接: https: //docs.nativescript.org/ui/styling#supported-measurement-units


Bol*_*ock 3

您链接到的文档在“支持的属性”部分的 font-size 属性下提到了“与设备无关的单位”,这表明 NativeScript 实际上本身并不使用任何测量单位,并且所有长度都以数字而不是尺寸表示,强调这一点。