JuneDeng


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

a-pixel-is-not-a-pixel

发表于 2017-06-05 | 分类于 技术

The tricky bits

However, there are two tricky bits: the device-width media query and the ≶meta name=”viewport” width=”device-width” >tag. Both work with device pixels, and not with CSS pixels, because they report on the context of the web page, and not on its inner CSS workings.
device-width媒体查询和≶ meta name=”viewport” width=”device-width” >都是指设备像素,而不是css像素。

The media query

The device-width media query measures the width of the device in device pixels. The width media query measures the total width of the page in CSS pixels, which, for reasons I’ll explain later, is at least 980px on the iPhone.
The device-width media query works as follows:

1
2
3
4
5
6
7
8
9
10
11
div.sidebar {
width: 300px;
}

@media all and (max-device-width: 320px) {
// styles assigned when device width is smaller than 320px;
div.sidebar {
width: 100px;
}

}

Now the sidebar is 300 CSS pixels wide, except when the device width is 320 device pixels or less, in which case it becomes 100 CSS pixels wide.
侧边栏为300 css像素宽,除非设备的宽度小于等于320,此时,侧边栏的css像素变为100px.
By the way, in theory you could use a media query that queries the device screen in centimeters or inches (@media all and (max-device-width: 9cm)). Unfortunately it seems badly to outright unsupported, even by the iPhone. The problem here is that physical units such as inches are usually translated to (CSS) pixels; thus width: 1in equals 96 pixels on all browsers I tested so far (and that’s quite a few). So these media queries are unreliable.
理论上说可以使用设备屏幕的厘米或者英寸来媒体查询。但是基本浏览器都不支持。

The tag

In general <meta name=”viewport” content=”width=device-width” > is even more useful. This tag, originally Apple-proprietary but meanwhile supported by many more mobile browsers, actually makes the layout viewport fit the device exactly.
Now what is the layout viewport? It’s the area (in CSS pixels) that the browser uses to calculate the dimensions of elements with percentual width, such as div.sidebar {width: 20%}. It’s usually quite a bit larger than the device screen: 980px on the iPhone, 850px on Opera, 800 on Android, etc.

If you add <meta name=”viewport” content=”width=device-width” >, the width of this layout viewport is constrained to the device width in device pixels; 320 of them in the iPhone’s case.

So basically Google has already inserted a layer of what are apparently called dips; device-independent pixels. This layer comes between the official, reported screen size and the CSS pixels web developers work with.

git add 详解

发表于 2017-06-05 | 分类于 技术

1、前言

git add命令主要用于把我们要提交的文件的信息添加到索引库中。当我们使用git commit时,git将依据索引库中的内容来进行文件的提交。

2、基本

git add < path >表示 add to index only files created or modified and not those deleted
通过git add < path >的形式把我们< path >添加到索引库中,< path >可以是文件也可以是目录。
git不仅能判断出< path >中,修改(不包括已删除)的文件,还能判断出新添的文件,并把它们的信息添加到索引库中。

3、git add -u

git add -u 表示 add to index only files modified or deleted and not those created git add -u [< path >]: 把< path >中所有tracked文件中被修改过或已删除文件的信息添加到索引库。它不会处理untracted的文件。
省略< path >表示.,即当前目录。

4、git add -A

git add -A: [< path >]表示把< path >中所有tracked文件中被修改过或已删除文件和所有untracted的文件信息添加到索引库。
省略< path >表示.,即当前目录。

5、git add -i

我们可以通过git add -i [< path >]命令查看< path >中被所有修改过或已删除文件但没有提交的文件,
并通过其revert子命令可以查看< path >中所有untracted的文件,同时进入一个子命令系统。

5.1、revert子命令

可以通过git add -i的revert子命令(3: [r]evert)把已经添加到索引库中的文件从索引库中剔除。
(3: [r]evert)表示通过3或r或revert加回车执行该命令。执行该命令后,git会例出索引库中的文件列表.
然后通过数字来选择。输入”1”表示git会例出索引库中的文件列表中的第1个文件。
“1-15”表示git会例出索引库中的文件列表中的第1个文件到第15个文件.回车将执行。
如果我们不输入任何东西,直接回车,将结束revert子命令,返回git add -i的主命令行。

5.2、update子命令

可以通过update子命令(2: [u]pdate)把已经tracked的文件添加到索引库中。其操作和revert子命令类似。

5.3、add untracked子命令

通过add untracked子命令(4: [a]dd untracked)可以把还没被git管理的文件添加到索引库中。其操作和revert子命令类似。

5.4、diff子命令

可以通过diff子命令(6: [d]iff)可以比较索引库中文件和原版本的差异。其操作和revert子命令类似。

5.5、status子命令

status子命令(1: [s]tatus)功能上和git add -i相似

5.6、quit子命令

quit子命令(7: [q]uit)用于退出git add -i命令系统

6、帮助

我们可以通过git add -h命令来看git add命令的帮助文档。

1…181920…32
June Deng

June Deng

make the world a better place

63 日志
2 分类
24 标签
GitHub
© 2018 June Deng
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4