CSS position屬性中absolute這個屬性是幹什麼用的?

來源:互聯網
上載者:User
css定位參數:position、left、right、top、bottom

參數說明:
absolute參數用來指定方塊的定位方式,top、bottom、left、right分別指定方塊的上下左右座標。
參數值說明。

  • absolute:絕對位置

  • fixed:固定定位

  • relative:相對定位

  • static:靜態定位

範例程式碼:

<!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><title>樣本網頁</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style>.c1{    width:200px;    height:150px;    line-height:75px;    text-align:center;    border:1px solid #909;    position:absolute;    top:50px;    left:50px;}</style></head><body><div class="c1">本方塊寬200px,高150px,絕對位置於上邊50px,左邊50px</div></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.