gzl的博客

  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

pip基础命令

发表于 2019-11-18 分类于 python

官网:https://pypi.org/

查看版本

1
pip -V

列出本地安装包

1
pip list

包安装

1
pip install [package_name]

包更新

1
pip install -U [package_name]

包卸载

1
pip uninstall [package_name]

包检索(服务器端)

1
pip search [package_keyword]

输出安装包的详细信息

1
pip freeze

显示本地安装包的详细信息

1
pip show [package_name]

pip自身更新

1
pip install --upgrade pip

帮助信息

1
pip --help

Flight rules for Git

发表于 2019-11-14 更新于 2019-11-18 分类于 git

https://github.com/k88hudson/git-flight-rules 阅读后摘抄不熟悉的地方(还有很多没看…)

Repositories

I set the wrong remote repository

There are a few possible problems here:

If you cloned the wrong repository, simply delete the directory created after running git clone and clone the correct repository.

If you set the wrong repository as the origin of an existing local repository, change the URL of your origin by running:

1
$ git remote set-url origin [url of the actual repo]

For more, see this StackOverflow topic.

I want to add code to someone else’s repository

https://github.com/k88hudson/git-flight-rules#i-want-to-add-code-to-someone-elses-repository

Editing Commits

What did I just commit?

Let’s say that you just blindly committed changes with git commit -a and you’re not sure what the actual content of the commit you just made was. You can show the latest commit on your current HEAD with:

1
(master)$ git show

Or

1
$ git log -n1 -p

If you want to see a file at a specific commit, you can also do this (where <commitid> is the commit you’re interested in):

1
$ git show <commitid>:filename

I wrote the wrong thing in a commit message

If you wrote the wrong thing and the commit has not yet been pushed, you can do the following to change the commit message without changing the changes in the commit:

1
$ git commit --amend --only

This will open your default text editor, where you can edit the message. On the other hand, you can do this all in one command:

1
$ git commit --amend --only -m 'xxxxxxx'

If you have already pushed the message, you can amend the commit and force push, but this is not recommended.

CSS-flex布局

发表于 2019-10-30 更新于 2019-12-15 分类于 CSS

Flex 布局是什么?

Flex 是 Flexible Box 的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性。

任何一个容器都可以指定为 Flex 布局。

行内元素也可以使用 Flex 布局。

1
2
3
.container {
display: flex; /* or inline-flex */
}

注意,设为 Flex 布局以后,子元素的float、clear和vertical-align属性将失效。

Note that float, clear and vertical-align have no effect on a flex item.

基本概念

采用 Flex 布局的元素,称为 Flex 容器(flex container),简称”容器”。它的所有子元素自动成为容器成员,称为 Flex 项目(flex item),简称”项目”。

容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end;交叉轴的开始位置叫做cross start,结束位置叫做cross end。

项目默认沿主轴排列。单个项目占据的主轴空间叫做main size,占据的交叉轴空间叫做cross size。

容器的属性

以下6个属性设置在容器上。

1
2
3
4
5
6
flex-direction
flex-wrap
flex-flow
justify-content
align-items
align-content

flex-direction

flex-direction属性决定主轴的方向(即项目的排列方向)。

它可能有4个值。

1
2
3
4
row(默认值):主轴为水平方向,起点在左端。
row-reverse:主轴为水平方向,起点在右端。
column:主轴为垂直方向,起点在上沿。
column-reverse:主轴为垂直方向,起点在下沿。

flex-wrap

默认情况下,项目都排在一条线(又称”轴线”)上。flex-wrap属性定义,如果一条轴线排不下,如何换行。

它可能取三个值。

1
2
3
nowrap(默认):不换行。
wrap:换行,第一行在上方。
wrap-reverse:换行,第一行在下方。

flex-flow

flex-flow属性是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap。

justify-content

justify-content属性定义了项目在主轴上的对齐方式。

它可能取5个值,具体对齐方式与轴的方向有关。下面假设主轴为从左到右。

1
2
3
4
5
flex-start(默认值):左对齐
flex-end:右对齐
center: 居中
space-between:两端对齐,项目之间的间隔都相等。
space-around:每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍。

align-items

align-items属性定义项目在交叉轴上如何对齐。

它可能取5个值。具体的对齐方式与交叉轴的方向有关,下面假设交叉轴从上到下。

1
2
3
4
5
flex-start:交叉轴的起点对齐。
flex-end:交叉轴的终点对齐。
center:交叉轴的中点对齐。
baseline: 项目的第一行文字的基线对齐。
stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度。

align-content

align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。

该属性可能取6个值。

1
2
3
4
5
6
flex-start:与交叉轴的起点对齐。
flex-end:与交叉轴的终点对齐。
center:与交叉轴的中点对齐。
space-between:与交叉轴两端对齐,轴线之间的间隔平均分布。
space-around:每根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍。
stretch(默认值):轴线占满整个交叉轴。

项目的属性

以下6个属性设置在项目上。

1
2
3
4
5
6
order
flex-grow
flex-shrink
flex-basis
flex
align-self

order

order属性定义项目的排列顺序。数值越小,排列越靠前,默认为0。

flex-grow

flex-grow属性定义项目的放大比例,默认为0,即如果存在剩余空间,也不放大。

如果所有项目的flex-grow属性都为1,则它们将等分剩余空间(如果有的话)。如果一个项目的flex-grow属性为2,其他项目都为1,则前者占据的剩余空间将比其他项多一倍。

flex-shrink

flex-shrink属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。

如果所有项目的flex-shrink属性都为1,当空间不足时,都将等比例缩小。如果一个项目的flex-shrink属性为0,其他项目都为1,则空间不足时,前者不缩小。

负值对该属性无效。

flex-basis

flex-basis属性定义了在分配多余空间之前,项目占据的主轴空间(main size)。浏览器根据这个属性,计算主轴是否有多余空间。它的默认值为auto,即项目的本来大小。

它可以设为跟width或height属性一样的值(比如350px),则项目将占据固定空间。

flex

flex属性是flex-grow, flex-shrink 和 flex-basis的简写,默认值为0 1 auto。后两个属性可选。

该属性有两个快捷值:auto (1 1 auto) 和 none (0 0 auto)。

建议优先使用这个属性,而不是单独写三个分离的属性,因为浏览器会推算相关值。

align-self

align-self属性允许单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。默认值为auto,表示继承父元素的align-items属性,如果没有父元素,则等同于stretch。

1
2
3
.item {
align-self: auto | flex-start | flex-end | center | baseline | stretch;
}

该属性可能取6个值,除了auto,其他都与align-items属性完全一致。

参考

Flex 布局教程:语法篇

a-guide-to-flexbox

1…789…32

gzl

96 日志
14 分类
37 标签
© 2020 gzl
由 Hexo 强力驱动 v3.7.1
|
主题 – NexT.Pisces v7.2.0