HTML基礎複習(六)布局-置中

來源:互聯網
上載者:User

標籤:不能   png   左右   src   水平   doctype   logs   添加   浮動   

讓最外層DIV在IE瀏覽器中水平置中:margin:0 auto                     margin是設定外邊距的,它有四個值,margin:4px 5px 5px 5px;分別表示上邊距,右邊距,下邊距,和左邊距,是從上按順時針設定的。  如果規定一個值,比如 div {margin: 50px} - 所有的外邊距都是 50 px  如果規定兩個值,比如 div {margin: 50px 10px} - 上下外邊距是 50px,左右外邊距是 10 px。margin:0 auto; 這其中0是上下邊距都是0,auto是自動調整大小(自動平分空白區),在這裡是左右邊距相同,就是置中了。  如果規定三個值,比如 div {margin: 50px 10px 20px}- 上外邊距是 50 px,而左右外邊距是 10 px,下外邊距是 20 px。  如果規定四個值,比如 div {margin: 50px 10px 20px 30px} - 上外邊距是 50 px,右外邊距是 10 px,下外邊距是 20 px,左外邊距是 30 px。  還可以margin-top:3px;margin-right:3px;margin-bott:om:3px;margin-left:3px;   margin:0 auto失效可能因素:  1、所在元素沒有設定寬度  2、所在元素不能浮動,否則無效  3、在某些瀏覽器中,需要給父級元素添加樣式:text-align: center;  4、在某些瀏覽器中,可能涉及到 <!DOCTYPE>類型相關定義。 

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.