Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

水平垂直居中的一点小心得 #6

Open
minbaowang opened this issue Jan 17, 2019 · 0 comments
Open

水平垂直居中的一点小心得 #6

minbaowang opened this issue Jan 17, 2019 · 0 comments

Comments

@minbaowang
Copy link
Owner

###水平垂直居中的一点小心得(笔者忽略定位居中,可自行了解)
//本文有点初级,大佬就别点进来看了,适合新手看这个攻略
##水平居中

1、text-align的用法

//新手最容易犯的小错误:没有清楚的认识到text-align只能用在行内元素上
text-align:center;//行内元素才能用

2、margin:0 auto;

//而在块级元素中,一般要居中某个元素,用margin:0 auto;
margin:0 auto;//块级元素用

3、justify-content:center;;

//而在响应式布局中,一般要居中某个元素,用justify-content:center;
display:block;
justify-content:center;//两句必须同时用

##垂直居中

1、line-height:height;和vertical-align:middle;
2、响应式布局flex下的垂直居中:align-items:center

display:flex;
align-items:center//写在父元素上,这样子元素才会居中
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant