css3中的display: table


今天看到一條屬性display: table; 可以在div等標簽中實現表格效果;


display: table=>相當於“table”標簽;

display: table-row=>相當於“tr”標簽;

display: table-cell=>相當於“td”標簽


一.父元素寬度固定,讓子元素平分寬度,用普通的方法設置%的時候是很煩的

  這里使用display: table;表格屬性來解決:

.parent{display: table;width: 800px;}

.son{display: table-cell;

  

二.塊級子元素垂直居中

.parent{display: table;width: 800px;}

.son{display: table-cell;}

三.display:table使用時應注意的一些問題

  1.display: table時 對應元素的padding會失效;

  2.display: table-row時 對應元素的padding、margin會失效;

  3..display: table-cell時 對應元素的margin會失效;

  4.displaty: table-cell不要與float,position: absolute;等改變布局的屬性同時使用,作用會被破壞

四.display:table;其他值

  1.table 此元素會作為塊級表單顯示=》

  2.table-row-group 此元素會作為一個或多個行的分組顯示=》tbody

  3.table-heightder-group 此元素會作為一個或多個行的分組顯示=》thead

  3.table-footer-grounp 此元素會作為一個或多個行的分組顯示=》tfoot

  4.table-column-grounp 此元素會作為一個或多個列的分組顯示=》colgroup

  5.table-column 此元素會作為一個單元格列顯示=>col

  6.table-caption 此元素會作為一個表格標題顯示=》caption

具體請參考張旭鑫老師的http://www.zhangxinxu.com/wordpress/2010/10/%E6%88%91%E6%89%80%E7%9F%A5%E9%81%93%E7%9A%84%E5%87%A0%E7%A7%8Ddisplaytable-cell%E7%9A%84%E5%BA%94%E7%94%A8/
posted @ 2018-07-10 17:43  漁小白  閱讀( 5070)  評論( 0編輯  收藏
,表格前后帶有換行符


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM