css設(shè)置不顯示元素的方法:1、使用【display: none;】方法;2、將【display:none;】改成【visibility: hidden;】
本教程操作環(huán)境:windows7系統(tǒng)、css3版,DELL G3電腦。
css設(shè)置不顯示元素的方法:
(1)display: none;
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style type="text/css"> .box { width: 160px; height: 100px; background: #cad5eb; } .title { height: 40px; background: #54a962; } .content { height: 60px; background: #5650bb; } </style> </head> <body> <div class="box"> <h3 class="title">標題</h3> <p class="content">內(nèi)容</p> </div> </body> </html>
設(shè)置display: none;后的效果如下顯示
可以看出原來的標題部分不見了,而內(nèi)容部分占領(lǐng)了原來標題的部分
(2)visibility: hidden;
還是上面的例子,只是這次將display:none;改成visibility: hidden; 但結(jié)果卻大不相同