<html> <head> <style> html, body, ul { margin: 0; padding: 0; } ul { width: 100%; height: 40rem; background: #000; display: flex; flex-wrap: wrap; justify-content: space-between; } li { width: 30%; height: 6rem; display: inline-block; background: #ededee; margin-top: 1rem; text-align: center; } ul:after { content: ""; width: 30%; height: 0px; visibility: hidden; } </style> </head> <body> <ul> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> </ul> </body> </html>
*重點在給外層的盒子加after