Html樣式布局複習

來源:互聯網
上載者:User

標籤:

<!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>格式布局</title><style type="text/css">*/*針對所有標籤起作用*/{    margin:0px;/*去除所有邊距magin表示靠近最近的邊*/    padding:0px;/*去除所有間距*/}.box{    opacity:0.5; moz-opactiy:0.5; filter:alpha(opacity=50)}</style></head><body>position 寫在樣式表裡,也可以寫在style裡<br />樣式表要優先於style<br />後寫的代碼要蓋住前寫的代碼<br />一、poistion:fixed<br />鎖定位置,例如有些網站的右下角彈窗廣告等<br />相對於瀏覽器的顯示頁面定位的<br /><div style="width:100px; height:100px; border::5px solid blue; background-color:#090;right:0px; bottom:0px; position:fixed;">fixed顯示位置</div>二、position:absolute   絕對位置<br />(1)外層沒有position:absolute(或relative)那麼div相對於heml頁面定位。<br />(2)外層如果有position:absolute(或relative)那麼div相對於外層邊框定位<br /><div  style=" border:2px solid red; width:400px; height:200px; ">c</div><div  style=" border:2px solid red; width:400px; height:200px; position:absolute; ">absolute外層無position:absolute<div style="border:1px solid red; width:100px; height:100px; right:30px; bottom:50px; position:absolute">position:absolute有外層position:absolute</div></div><div style="border:1px solid red; width:100px; height:100px; right:30px; bottom:50px; background:#FF0; position:absolute">position:absolute外層無position</div><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />三、position:relative<br />相對於預設位置static的移動。自我理解為相對於div插入位置重新定義位置<br /><div style="width:100px; height:100px; border:5px solid blue;  top:30px; left:100px; position:relative">relative介面圖</div><br /><br /><br /><br />四、分層(z-index:)<br />在z軸方向分層,可以理解為一摞紙,層數越高越靠上。<br />z-index值預設為1,需要位於上面的值大於下面的值<br /><div style="border:1px solid orange; width:100px; height:100px; left:30px; top:30px; position:relative; background-color:#00C;z-index:2">分層1</div><div style="border:1px solid orange; width:100px; height:100px; left:50px; bottom:50px; position:relative; ">分層2</div><br /><br />overflow:hidden;//超出部分隱藏;scroll,顯示捲軸<br /><div style="border:1px solid orange; width:100px; height:100px; left:30px; top:30px; position:relative; background-color:#00C;overflow:hidden;">分層1<div style="border:1px solid orange; width:100px; height:100px; left:50px; bottom:50px; position:relative; background-color:#00C;">分層2</div></div><br /><br /><br /><br />五、float:left、right<br /><!--<div style="clear:both"></div>  截斷流 --><div style="border:1px solid orange; width:50px; height:100px;   background-color:#00C;float:left;">1</div><div style="border:1px solid orange; width:50px; height:100px;  background-color:#00C;float:right;">2</div><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />半透明效果<br /><div   style="background:#900;"class="box">透明地區</div></body></html>

Html樣式布局複習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.