<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grid Demo</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
font-size: 16px;
max-width: 800px;
}
.container {
width: 100vw;
display: grid;
grid-template-columns: repeat(auto-fit, 22.5vw); /* 22.5vw可调整,则自适应 */
justify-content: space-between;
grid-row-gap: 10px;
}
.container > div {
border-radius: 25%;
padding: 10px;
background-color: rgb(207, 232, 220);
border: 2px solid rgb(79, 185, 227);
aspect-ratio: 1;
}
</style>
</head>
<body>
<div class="container">
<div class="one">one</div>
<div class="two">tow</div>
<div class="three">three</div>
<div class="four">four</div>
<div class="five">five</div>
<div class="six">six</div>
<div class="seven">seven</div>
<div class="eight">eight</div>
</div>
</body>
</html>
标签:container,10px,个数,宽高,grid,vw,Grid,border
From: https://www.cnblogs.com/pangqianjin/p/17204408.html