亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

CSS的box-align屬性控制子元素布局實(shí)例

css3html5   發(fā)布時(shí)間:2016-07-01 11:30:23   作者:ttwinbug   我要評論
box-align可以控制盒模型內(nèi)部的子元素的縱向排列,這里我們就來看一個(gè)CSS的box-align屬性控制子元素布局實(shí)例,首先還是先來回顧一下box-align屬性的使用要點(diǎn):

box-align 說明
box-align屬性, 指定元素內(nèi)子要素縱方向排列指定時(shí)使用。<規(guī)定框中子元素的顯示次序。>
容器元素比子元素大很多的情況下,使用box-align屬性,可以指定子元素的排序順序,并且可以指定子元素如何表示。
還有,縱方向排列一說,可以解釋為元素內(nèi)子元素的配置方向默認(rèn)值為水平,使用此屬性后垂直方向進(jìn)行排列。也可以使用 box-orient:vertical來設(shè)置子元素排列方向。

屬性值
start:標(biāo)準(zhǔn)方向元素,各子要素上端沿著元素上端進(jìn)行排列,余下的位置向下排序, 反方向元素的話,則沿著下端進(jìn)行排序,余下的位置向上排序。<對于正常方向的框,每個(gè)子元素的上邊緣沿著框的頂邊放置。 對于反方向的框,每個(gè)子元素的下邊緣沿著框的底邊放置。>
end:標(biāo)準(zhǔn)方向元素,各子要素下端沿著元素下端進(jìn)行排列,余下的位置向上排序, 反方向元素的話,則沿著上端進(jìn)行排序,余下的位置向下排序。<對于正常方向的框,每個(gè)子元素的下邊緣沿著框的底邊放置。 對于反方向的框,每個(gè)子元素的上邊緣沿著框的頂邊放置。>
center:剩余空間,進(jìn)行均等分配。<均等地分割多余的空間,一半位于子元素之上,另一半位于子元素之下。>
baseline:inline-axis和horizontal的場合,所有子元素baseline配置排列<如果 box-orient 是inline-axis或horizontal,所有子元素均與其基線對齊。>
stretch:各子元素按照容器元素的高來自動(dòng)排序(默認(rèn)值)

關(guān)于居中
原來水平垂直居中寫法為:height=line-height 實(shí)現(xiàn)垂直居中text-align實(shí)現(xiàn)水平居中
現(xiàn)在使用box-align實(shí)現(xiàn)垂直居中box-pack 實(shí)現(xiàn)水平居中

CSS Code復(fù)制內(nèi)容到剪貼板
  1. <!DOCTYPE html>   
  2.   
  3. <html>   
  4. <head>   
  5.     <title>水平及垂直居中</title>   
  6. </head>   
  7. <body >   
  8. <div style="width:300px; height: 300px; background-color: #ccc;  
  9.   line-height: 300px; text-align: center;">   
  10.     <input type="button" value="原有居中方式">   
  11. </div>   
  12. <div style="width:300px; height: 300px; background-color: #aaa;  
  13.  display:-webkit-box;-webkit-box-pack: center;  
  14.    ; -webkit-box-align:center">   
  15.     <input type="button" value="css3的居中方式">   
  16. </div>   
  17. </body>   
  18. </html>  

實(shí)例代碼

CSS Code復(fù)制內(nèi)容到剪貼板
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  2. <html xmlns="http://www.w3.org/1999/xhtml">   
  3. <head>   
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
  5. <title> box-align </title>   
  6. <style>   
  7. div.prefix_sample1 {   
  8. width:500pxheight:100px;   
  9. background-color:yellow;   
  10. display:-moz-box;   
  11. display:-webkit-box;   
  12. display:-o-box;   
  13. display:-ms-box;   
  14. -moz-box-align:start;   
  15. -webkit-box-align:start;   
  16. -o-box-align:start;   
  17. -ms-box-align:start;   
  18. }   
  19. div.prefix_sample2 {   
  20. width:500pxheight:100px;   
  21. background-color:yellow;   
  22. display:-moz-box;   
  23. display:-webkit-box;   
  24. display:-o-box;   
  25. display:-ms-box;   
  26. -moz-box-align:end;   
  27. -webkit-box-align:end;   
  28. -o-box-align:end;   
  29. -ms-box-align:end;   
  30. }   
  31. div.prefix_sample3 {   
  32. width:500pxheight:100px;   
  33. background-color:yellow;   
  34. display:-moz-box;   
  35. display:-webkit-box;   
  36. display:-o-box;   
  37. display:-ms-box;   
  38. -moz-box-align:center;   
  39. -webkit-box-align:center;   
  40. -o-box-align:center;   
  41. -ms-box-align:center;   
  42. }   
  43. div.prefix_sample4 {   
  44. width:500pxheight:100px;   
  45. background-color:yellow;   
  46. display:-moz-box;   
  47. display:-webkit-box;   
  48. display:-o-box;   
  49. display:-ms-box;   
  50. -moz-box-align:baselinebaseline;   
  51. -webkit-box-align:baselinebaseline;   
  52. -o-box-align:baselinebaseline;   
  53. -ms-box-align:baselinebaseline;   
  54. }   
  55. div.prefix_sample5 {   
  56. width:500pxheight:100px;   
  57. background-color:yellow;   
  58. display:-moz-box;   
  59. display:-webkit-box;   
  60. display:-o-box;   
  61. display:-ms-box;   
  62. -moz-box-align:stretch;   
  63. -webkit-box-align:stretch;   
  64. -o-box-align:stretch;   
  65. -ms-box-align:stretch;   
  66. }   
  67.     
  68. div.aka {background-color:red;}   
  69. div.midori {background-color:green;}   
  70. div.ao {background-color:blue;}   
  71. </style>   
  72.     
  73. </head>   
  74.     
  75. <body>   
  76. <h4>box-align:start;</h4>   
  77. <div class="prefix_sample1">   
  78. <div class="aka">abcde</div>   
  79. <div class="midori">abcde</div>   
  80. <div class="ao">abcde</div>   
  81. </div>   
  82.     
  83. <h4>box-align:end;</h4>   
  84. <div class="prefix_sample2">   
  85. <div class="aka">abcde</div>   
  86. <div class="midori">abcde</div>   
  87. <div class="ao">abcde</div>   
  88. </div>   
  89.     
  90. <h4>box-align:center; </h4>   
  91. <div class="prefix_sample3">   
  92. <div class="aka">abcde</div>   
  93. <div class="midori">abcde</div>   
  94. <div class="ao">abcde</div>   
  95. </div>   
  96.     
  97. <h4>box-align:baselinebaseline; </h4>   
  98. <div class="prefix_sample4">   
  99. <div class="aka">abcde</div>   
  100. <div class="midori">abcde</div>   
  101. <div class="ao">abcde</div>   
  102. </div>   
  103.     
  104. <h4>box-align:stretch; </h4>   
  105. <div class="prefix_sample5">   
  106. <div class="aka">abcde</div>   
  107. <div class="midori">abcde</div>   
  108. <div class="ao">abcde</div>   
  109. </div>   
  110.     
  111. </body>   
  112. </html>  

實(shí)例圖
201671113215249.jpg (514×802)

相關(guān)文章

最新評論