CSS中如何让色块居中呢?实际上有很多种方法,下面我们就一起来看看。首先,我们需要先创建一个色块: <div class= color-block ></di
<div class="color-block"></div>
<style> .color-block{ width: 100px; height: 100px; background-color: #f00; text-align: center; } </style>
<style> .color-block{ width: 100px; height: 100px; background-color: #f00; margin: 0 auto; } </style>
<style> .container{ display: flex; justify-content: center; align-items: center; height: 100vh; } .color-block{ width: 100px; height: 100px; background-color: #f00; } </style> <div class="container"> <div class="color-block"></div> </div>
粉丝
0
关注
0
收藏
0