Skip to content

45.[CSS]如何居中一个浮动元素? #45

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

Open
webVueBlog opened this issue Mar 15, 2020 · 1 comment
Open

45.[CSS]如何居中一个浮动元素? #45

webVueBlog opened this issue Mar 15, 2020 · 1 comment
Labels
css css

Comments

@webVueBlog
Copy link
Member

No description provided.

@webVueBlog webVueBlog added the css css label Mar 15, 2020
@webVueBlog
Copy link
Member Author

方法一:让最外面的层相对定位,left 等于 50%,然后内部嵌套层也使用相对定位且 left 设为-50%,这样的效果就是内层相对整行为水平居中;

方法二:使用 display: table;

方法三:直接使用 table 布局(使用太多 table 容易让结构看起来比较混乱, 其实页面中使用少量的 table,只要不要嵌套使用,还是可以实现使用少量 CSS,达 到最好的效果的),这种方法这里就不举例演示了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css
Projects
None yet
Development

No branches or pull requests

1 participant