<style>.
方法四
box4{
width: 300px;
height: 300px;
border: 2px solid green;
/* background-color: pink; */
/* margin: 100px auto; */
/* 相对定位 */
position: relative;
/* 第四种(flexbox) */
display: flex;
/* 主轴方向对齐方式 */
justify-content: center;
/* 交叉轴方向对齐方式 */
align-items: center; }
.box4>div{
width: 100px;
height: 100px;
background-color: pink; }
</style>
<div class="box4"><div>方法4</div></div>
本文介绍了使用Flexbox进行网页布局的方法四,通过展示如何将一个300x300px的div及其内部100x100px粉色方块居中对齐,讲解了justify-content和align-items属性在实现响应式设计中的关键作用。
1510

被折叠的 条评论
为什么被折叠?



