css display:none和visibility:hidden和visible=”false”區別

來源:互聯網
上載者:User

如果在div的style中把visibility設為hidden則div隱藏,但是它會佔據空白空間,而如果設定成display:none則不佔據空白空間;
而visible="false"則div不返回在html中;下面是給出的代碼:運行一下就知道區別了。

<%@ Page Language="C#" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

 

<title>Untitled Page</title>

</head>

<body>

 

<form id="form1" runat="server">

 

<div>

 

aaa

</div>

 

<div style=" display:none;"><%--不佔據空白空間--%>

aaa

</div>

 

<div>

 

aaa

</div>

 

<div>

 

aaa

</div>

 

<div style="visibility:hidden"><%--佔據空白空間--%>

aaa

</div>

 

<div id="Div1" runat="server" visible="false">bbbbbbb</div>

 

<div>

 

aaa

</div>

 

<div id="Div2" runat="server" visible="false">bbbbbbb</div><%--在html中不存在--%>

</form>

</body>

</html>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.