结果展示:
实现思路:
· 媒体查询 来实现适配不同尺寸屏幕
· flex 来实现多行多列
代码如下:
.father {
display: flex;
flex-wrap: wrap;
width: 70%;
margin: auto;
background-color: blueviolet;
}
@media screen and (min-width: 100px) {
.father button {
width: 100%;
height: 100px;
}
}
@media screen and (min-width: 300px) {
.father button {
width: 33.33%;
height: 100px;
}
}
@media screen and (min-width: 414px) {
.father button {
width: 25%;
height: 100px;
}
}
@media screen and (min-width: 750px) {
.father button {
width: 20%;
height: 100px;
}
}
@media screen and (min-width: 1024px) {
.father button {
width: calc(100%/6);
height: 100px;
}
}
<div class="father">
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
<button>6</button>
<button>7</button>
</div>