HTML5 发展如火如荼,随着各大浏览器对 HTML5 技术支持的不断完善以及 HTML5 技术的不断成熟,未来 HTML5 必将改变我们创建 Web 应用程序的方式。今天这篇文章向大家推荐10款优秀的HTML5开发工具,帮助你更高效的编写…
February 9, 2016
CSS:absolute居中 How to center absolute div horizontally using CSS
You need to set left:0; right:0;
.
This specifies how far to offset the margin edges from the sides of the window.
http://www.w3.org/TR/CSS2/visuren.html#position-props
CSS
.container { position: absolute; top: 15px; z-index: 2; width:40%; max-width: 960px; min-width: 600px; height: 60px; overflow: hidden; background: #fff; margin: 0 auto; left: 0; right: 0; }
Note: You must define the width or this Answer will not work. That means this answer is not useful for elements with dynamic widths.
share from: http://stackoverflow.com/a/17977312
本文:CSS:absolute居中 How to center absolute div horizontally using CSS