Css格式與布局

來源:互聯網
上載者:User

標籤:flow   自身   更改   位置   就會   idt   技術分享   使用   bsp   

 

一、位置

1、絕對位置

position:absolute:絕對位置。

絕對位置的意思就是相對於瀏覽器邊框的位置,迴歸到它應有的位置。也就是說,一個div使用絕對位置後是在瀏覽器邊框的最左上方位置。而此時,可以利用上下左右的標籤變更位置。

            #a1{                width: 200px;                height: 200px;                background-color: burlywood;                position:absolute;                top: 10px;                left: 10px;            }        </style

 

 

2、固定位置

position:fixd:固定位置

同樣的,固定位置也是相對有瀏覽器邊框而定。但注意的是,值不可為負。

position:fixed;

 

 

3、相對位置

position:relative:相對位置

相對於自身原來出現的位置,進行移動。

            #a1{                width: 200px;                height: 200px;                background-color: burlywood;                position: relative;                top: 50px;                    }

 

 

二、流

1、float:流

往哪個方向流,那麼元素就跟著全部往哪個方向去。

            #liu{                width: 900px;                height: 50px;            }            .lift{                    float: left;                            }            

 

2、清流

不管是float還是position,都是浮在上面一層。當我們都使用float流的時候,下面的一層就會覆蓋住上面一層。而這個時候避免出現問題,我們就需要清流。

Bug:

 

這個時候就需要我們清除一個流:

clear:both:清除所有

 

 

三、文字樣式置中

            .lift{                    float: left;                width: 100px;                height: 50px;                text-align: center;                vertical-align: middle;                line-height: 50px;                margin-left: 7px;                background-color: cornflowerblue;                            }

 

 

四、Z-index分層

相當於Z軸的一個序號。

屬性設定元素的堆疊順序。擁有更高堆疊順序的元素總是會處於堆疊順序較低的元素的前面。

Z-index 只能在定位元素上有效果(例如 position:absolute;)

 

 

            #no1{                width: 200px;                height: 100px;                background-color:black;                position: absolute;                z-index: 2;            }            #no2{                width: 300px;                height: 50px;                background-color: yellow;                position: absolute;                z-index: 1;            }            

 

 

 

Z-index的值越大越靠上

 

Css格式與布局

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.