最好使用 CSS 将表格垂直居中
我正在寻找如何将元素(表格)垂直居中的运气不佳。我尝试了 CSS 垂直对齐:中间;这不起作用我也尝试了 margin-top: auto;下边距:自动;这也不起作用。我还使用了表属性 valign 作为“中间”,但仍然不起作用。我正在使用 Chrome,但也在 IE 中测试了所有这些策略,结果相同。
I am looking without much luck how to center an element (a table) vertically. I tried CSS vertical-align: middle; which did not work I also tried margin-top: auto; margin-bottom: auto; which also did not work. I also used the table attribute valign as "middle" which still did not work. I am using Chrome but have tested all these strategies in IE as well with the same results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里是一个页面,展示了实现此目的的技术和如何在几个不同的场景中使用它。此方法有一个问题,因为它依赖于您知道要垂直居中的元素的高度。如果您不知道这一点,那么这对您不起作用。
Here is a page which shows a technique to accomplish this and a how to use it in a couple different scenarios. This method has one issue since it relies on you knowing the height of the element you want to vertically center. If you don't know that then this will not work for you.