CSS3.0盒子模型:display:-webkit-box

來源:互聯網
上載者:User

標籤:style   blog   color   io   strong   ar   art   div   cti   

 1 <!DOCTYPE html> 2 <html> 3 <head> 4   <title>css3盒子模型</title>   5   <style> 6   .box3{ 7     width: 300px; 8     height: 100px; 9     /*設定css3盒子模型的父類*/10     display: -webkit-box;11     display: -moz-box;12     display: box;13 14     background-color: #1d89cf;15   }16   .box3>section{17     /*設定css3盒子模型的子類,將他們平分*/18     -webkit-box-flex: 1;19     -moz-box-flex: 1;20     box-flex: 1;21 22     border: 1px solid #fff;23     text-align: center;24   }25   </style>26 </head>27 28 <body>29 30 <div class="box3">31   <section>1</section>32   <section>2</section>33   <section>3</section>34 </div>35 36 </body>37 </html>

上面就是css3盒子模型最基本的一個代碼。

display:-*-box; 是定義盒子模型的父容器。

-*-box-flex: 1; 是定義盒子模型的子容器在父容器中的比例。

如是1,2,1,意思就是section1、2、3分別佔25%,50%,25%。

 

而-*-box有如下屬性:

-*-box-orient: horizontal | vertical | inline-axis | block-axis | inherit

用來確定父容器中的子容器的布局是水平布局還是垂直布局。(預設水平)

 

-*-box-direction: normal | reverse | inherit

用來確定子容器的排列順序,如是reverse,就是將123在頁面中變成了321的排列

 

-*-box-align:start(頂對齊) | end(底對齊) | center(置中對齊) | baseline | stretch(展開,展開到和父容器等高)

用來確定子容器的垂直對齊。

 

-*-box-pack: start | end | center | justify

用來確定子容器的水平對齊。

CSS3.0盒子模型:display:-webkit-box

聯繫我們

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