html grid布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div class="wrapper"> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> <div class="item"> 测试 </div> </div> </body> <style> .wrapper { width: 100vw; display: grid; grid-template-columns: repeat(4, 1fr); justify-content: space-between; } .wrapper .item { line-height: 170%; background-color: beige; border-radius: 20px; margin: 20px; padding: 20px; text-align: center; } .wrapper .item:hover { line-height: 170%; background-color: rgb(160, 188, 207); border-radius: 20px; margin: 20px; padding: 20px; } </style> </html>