如何居中一个浮动元素?如何让绝对定位的div居中?
div居中:
border: 1px solid red; margin: 0 auto; height: 50px; width: 80px;
浮动元素的上下左右居中:
border: 1px solid red; float: left; position: absolute; width: 200px; height: 100px; left: 50%; top: 50%; margin: -50px 0 0 -100px;
绝对定位的左右居中:
border: 1px solid black; position: absolute; width: 200px; height: 100px; margin: 0 auto; left: 0; right: 0;
推荐教程:css快速入门
以上就是如何居中一个浮动元素?如何让绝对定位的div居中?的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号