(3)为父盒子添加border
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>嵌套盒子</title> <style> #parent{ width: 300px; height: 300px; background-color: #FF6600; overflow: hidden; } #child{ width: 150px; height: 150px; background-color: #cccccc; margin: 0 auto; margin-top: 75px; } </style> </head> <body> <div id="parent"> <div id="child"></div> </div> </body> </html>