CSS進階技巧

來源:互聯網
上載者:User

標籤:between   利用   span   彈性   flex   master   item   不同的   文章   

使用CSS複位

CSS複位可以在不同的瀏覽器上保持一致的樣式風格。您可以使用CSS reset 庫Normalize等,也可以使用一個更簡化的複位方法:·

* {  box-sizing: border-box;  margin: 0;  padding: 0;}

現在元素的 margin 和 padding 已為0,box-sizing可以管理您的CSS盒模型布局。

繼承  box-sizing

從 html 元素繼承 box-sizing :

 

html {  box-sizing: border-box;}*, *:before, *:after {  box-sizing: inherit;}
body 元素添加行高

不必為每一個 <p><h*> 元素逐一添加 line-height,直接添加到 body 元素:·

body {  line-height: 1.5;}
水平垂直置中任何元素

利用彈性盒子來實現

html, body {  height: 100%;  margin: 0;}body {  display: -webkit-flex;  display: flex;  justify-content: center;/*水平置中*/  -webkit-align-items: center; /*垂直置中相容*/   align-items: center;/*垂直置中*/}
利用 Flexbox 去除多餘的外邊距
.list {  display: flex;  justify-content: space-between;}.list .person {  flex-basis: 23%;}

本文來自:https://github.com/AllThingsSmitty/css-protips/tree/master/translations/zh-CN#table-of-contents

推薦文章

  • 20個很有用的CSS技巧
  • CSS粘住固定底部的5種方法
  • 移動端CSS平分等分布局延伸

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.