-
Notifications
You must be signed in to change notification settings - Fork 24
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
总结一些DIV居中的方法 #3
Milestone
Comments
多谢分享,很是感谢 |
感谢分享: ) |
感谢分享;+利用绝对定位,transform来居中。 |
很赞,补充一点:
|
thank you! |
thank you |
Good! |
前端面试必备.. |
多谢! |
#parent { #item { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
总结下使DIV居中的不同方法。
1.:+1:the better method:
可参考How to Center Anything With CSS
👏👏👏
考虑多浏览器兼容性的话 display: table or display: inline-block;
2.宽度高度不固定DIV水平居中
html部分
css部分
代码要点:
3.宽度高度不固定DIV垂直居中
html部分
css部分
代码要点:
4.宽度高度固定水平垂直居中
html部分
css部分
代码要点:
5. 然后CSS3来了,使用flexbox布局
抛开兼容性,我想这是一个完美的居中,不需要考虑宽度和高度值。
The text was updated successfully, but these errors were encountered: