- display:none
隐藏元素,不保留位置,文档结构中存在 - visibility:hidden
隐藏元素,仍占有原来位置
<!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>display none</div> <div>visibility hidden</div> </body> </html> <style> div:nth-child(1) { width: 100px; height: 100px; background-color: #e99; /* display: none; */ visibility: hidden; } div:nth-child(2) { width: 100px; height: 100px; background-color: green; } </style>
标签:none,元素,100px,visibility,display,hidden,隐藏,css From: https://www.cnblogs.com/dming4/p/17573232.html