<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.box-wrapper {
width: 500px;
height: 500px;
background-color: orange;
}
.box{
width: 400px;
height: 200px;
margin: 0 auto;
/*当父元素水平空间不足,设置右外边距失效,优先保证左外边距*/
margin: 0 200px;
}
.box-1{
background-color: pink;
}
</style>
</head>
<body>
<div class="box-wrapper">
<div class="box box-1"></div>
</div>
<script type="text/javascript">
</script>
</body>
</html>
HTML5基础加强css样式篇(右外边距失效问题解释)(四十八)
最新推荐文章于 2023-04-18 14:37:54 发布