css一些特別效果設定

來源:互聯網
上載者:User

標籤:

在CSS中,BOX的Padding屬性的數值賦予順序為

 

padding:10px;                           四個內邊距都是10px
padding:5px 10px;   上下5px 左右10px
padding:5px 10px 15px; 上5px 右10px 下15px 左因為預設與右相等,則為10px
padding:5px 10px 15px 20px; 上5px 右10px 下15px  左20px



div水平和垂直置中,text-align和vertical-align不起作用,因為標籤div沒有這兩個屬性,所以再css中設定這兩個值不能置中的效果。

1. div水平置中:設定margin的左右邊距為自動。

1 div2 {3      margin:0 auto;4 }

2.   div中的元素置中

2.1 div中的文字置中:將div的行高設定跟其高度一樣的值。

1 div2 {3     height:200px;4     line-height:200px;5 }

2.2 div中的圖片置中,方法一:將div的行高設定跟其高度一樣的值,將其中的圖片img外套上標籤i,設定i和div同時垂直置中

 1 div 2 { 3     width: 200px; 4     height: 200px; 5     line-height: 200px; 6     vertical-align: middle; 7     background-color: Gray; 8 } 9 div i10 {11     vertical-align: middle;12 }

2.3 div中的圖片置中,方法二:將div轉換成tablecell,讓後設定vertical-align屬性置中。

1 div2 {3     width: 200px;4     height: 200px;5     display: table-cell;6     vertical-align: middle;7     background-color: Gray;8 }
 
 

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.