CSS3盒模型display:-webkit-box;的使用

來源:互聯網
上載者:User

標籤:style   blog   color   使用   width   html   

box-flex是css3新添加的盒子模型屬性,它的出現可以解決我們通過N多結構、css實現的布局方式。經典的一個布局應用就是布局的垂直等高、水平均分、按比例劃分。目前box-flex屬性還沒有得到firefox、Opera、chrome瀏覽器的完全支援,但可以使用它們的私人屬性定義firefox(-moz)、opera(-0)、chrome/safari(-webkit)。 box-flex主要讓子容器針對父容器的寬度按一定規則進行劃分。舉個栗子:
<!DOCTYPE html><html><meta charset="utf-8" /><style>.wrap {    display: -webkit-box;    -webkit-box-orient: horizontal;}.child {    min-height: 200px;    border: 2px solid #666;    margin: 10px;    font-size: 40px;    font-weight: bold;    font-family: Georgia;    -webkit-box-align: center;}.w200 {width: 200px}.flex1 {display:block;-webkit-box-flex: 3}.flex2 {display:block;-webkit-box-flex: 1}</style><div class="wrap">    <!-- <div class="child w200">200px</div>    <div class="child flex1">比例1</div>    <div class="child flex2">比例2</div> -->    <input type="text" class="child flex1" value="比例1">    <input type="text" class="child flex2" value="比例2"></div></html>

Ps:例如上面的child要求是塊(block)元素才有效。

聯繫我們

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