你可以使用唯一的CSS獲得一個響應表,當你需要瀏覽器屏幕然後你分開行。我希望當你看到這個代碼看到這個鏈接jsfiddle.net你會明白如何使用CSS響應表。
@media screen and (max-width: 700px) {
.width_one, .width_two, .width_three, .width_four { width:inherit;}
.ncprg_table tr.bg_title { display: none; }
.ncprg_table,
.ncprg_table thead,
.ncprg_table tbody,
.ncprgtable th,
.ncprg_table td,
.ncprg_table tr {
display: block;
}
.ncprg_table { padding: 0; }
.ncprg_table thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
.ncprg_table tr {
padding:0px;
}
.ncprg_table td {
border: none;
border-bottom: 1px solid #747474;
position: relative;
padding-left: 140px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
padding-top:19px;
}
.ncprg_table td {
height:38px;
}
.ncprg_table td:before {
position: absolute;
top: 20px;
left: 0;
width:140px;
padding:0 10px 0 15px;
white-space: nowrap;
font-size:13px;
color:#747474;
text-align:left;
}
.ncprg_table td:nth-of-type(1):before { content: "Standard - CPR/AED"; }
.ncprg_table td:nth-of-type(2):before { content: "Modules"; }
.ncprg_table td:nth-of-type(3):before { content: "Training"; }
.ncprg_table td:nth-of-type(4):before { content: "Validity"; }
.ncprg_table td:nth-of-type(5):before { content: "Certification"; }
.ncprg_table td:nth-of-type(6):before { content: "Duration"; }
.ncprg_table td:nth-of-type(7):before { content: "AHA & ECC"; }
.ncprg_table td:nth-of-type(8):before { content: "Exam Attempts"; }
.ncprg_table td:nth-of-type(9):before { content: "Vinyl Wallet Card"; }
.ncprg_table td:nth-of-type(10):before { content: "Cert. & Card Download"; }
.ncprg_table th,
.ncprg_table td {
font-size: 13px;
}
}
如果你用overflow-x:auto將整個東西包裝在一個div中,它應該自動處理在屏幕太窄而不能顯示完整數據集的屏幕上滾動。這不是最美觀的,但它會爲您節省很多頭痛,而不是嘗試垂直襬放桌子。 – delinear
https://css-tricks.com/responsive-data-tables/ – VXp