vue vue的table表格自适应_响应式表格,HTML表格自适应(responsive table)
簡單自適應(yīng)表格
前面的一篇文章里面我介紹到了一種簡單的自適應(yīng)表格制作方案,就是通過給表格的外面加了一個.table-container的標(biāo)簽
.table-container
{
width: 100%;
overflow-y: auto;
_overflow: auto;
margin: 0 0 1em;
}
table{border:0; border-collapse:collapse;}
table td,table th{border:1px solid #999; padding:.5em 1em}
//添加IOS下滾動條
.table-container::-webkit-scrollbar
{
-webkit-appearance: none;
width: 14px;
height: 14px;
}
.table-container::-webkit-scrollbar-thumb
{
border-radius: 8px;
border: 3px solid #fff;
background-color: rgba(0, 0, 0, .3);
}
演示1
bootstrap3自適應(yīng)表格
Bootstrap3.0也類似這樣子的簡單自適應(yīng),當(dāng)屏幕小于767像素時,表格就會自適應(yīng),多的隱藏可以滾動。
@media (max-width: 767px) {
.table-responsive {
width: 100%;
margin-bottom: 15px;
overflow-x: scroll;
overflow-y: hidden;
border: 1px solid #dddddd;
-ms-overflow-style: -ms-autohiding-scrollbar;
-webkit-overflow-scrolling: touch;
}
.table-responsive > .table {
margin-bottom: 0;
}
.table-responsive > .table > thead > tr > th,
.table-responsive > .table > tbody > tr > th,
.table-responsive > .table > tfoot > tr > th,
.table-responsive > .table > thead > tr > td,
.table-responsive > .table > tbody > tr > td,
.table-responsive > .table > tfoot > tr > td {
white-space: nowrap;
}
隱藏表格欄目
隨著屏幕寬度變小而刪除一些內(nèi)容,該技術(shù)來源這里
@media only screen and (max-width: 800px) {
#unseen table td:nth-child(2),
#unseen table th:nth-child(2) {display: none;}
}
@media only screen and (max-width: 640px) {
#unseen table td:nth-child(4),
#unseen table th:nth-child(4),
#unseen table td:nth-child(7),
#unseen table th:nth-child(7),
#unseen table td:nth-child(8),
#unseen table th:nth-child(8){display: none;}
}
翻轉(zhuǎn)滾動表格
當(dāng)屏幕寬度小于800時,表格內(nèi)容則會發(fā)生翻轉(zhuǎn),表頭的內(nèi)容會放在左邊。右邊則是會出現(xiàn)滾動,超出的隱藏。這個要求是表格比較完整,不然不是很好看。在表格的外面加個#flip-scroll,該技術(shù)來源于這里
table tr td, table tr th{white-space:nowrap;}
@media only screen and (max-width: 800px) {
#flip-scroll .cf:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
#flip-scroll * html .cf { zoom: 1; }
#flip-scroll *:first-child+html .cf { zoom: 1; }
#flip-scroll table { width: 100%; border-collapse: collapse; border-spacing: 0; }
#flip-scroll th,
#flip-scroll td { margin: 0; vertical-align: top; }
#flip-scroll th { text-align: left; }
#flip-scroll table { display: block; position: relative; width: 100%; }
#flip-scroll thead { display: block; float: left; }
#flip-scroll tbody { display: block; width: auto; position: relative; overflow-x: auto; white-space: nowrap; }
#flip-scroll thead tr { display: block; }
#flip-scroll th { display: block; text-align: right; }
#flip-scroll tbody tr { display: inline-block; vertical-align: top; }
#flip-scroll td { display: block; min-height: 1.25em; text-align: left; }
/* sort out borders */
#flip-scroll th { border-bottom: 0; border-left: 0; }
#flip-scroll td { border-left: 0; border-right: 0; border-bottom: 0; }
#flip-scroll tbody tr { border-left: 1px solid #babcbf; }
#flip-scroll th:last-child,
#flip-scroll td:last-child { border-bottom: 1px solid #babcbf; }
}
沒有更多的表格
該項技術(shù)在這里靠的是使用HTML5的數(shù)據(jù)屬性(data)和CSS來讓他們顯示在表頭里面。另一個就是直接在CSS里面寫文字,但我們知道這個對于CSS來說是一個巨大禁忌。
另外還發(fā)現(xiàn)了一些結(jié)合了js使用的表格。
foundation的自適應(yīng)表格
來自有名的自適應(yīng)框架的博客的一篇文章,這個自適應(yīng)表格的使用比較符合常規(guī)使用,唯一不足的地方就是需要用到j(luò)Query代碼。
博客介紹 演示地址 下載源碼
我的自適應(yīng)表格
需求是這樣子的,左邊的表頭名一列不滾動,右邊的數(shù)據(jù)內(nèi)容超出要滾動。找了一篇,發(fā)現(xiàn)沒有符合我要求的,既然這樣,自己動手,豐衣足食。
詳情請訪問我的項目:相對自適應(yīng)表格
總結(jié)
以上是生活随笔為你收集整理的vue vue的table表格自适应_响应式表格,HTML表格自适应(responsive table)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab除法不对,matlab中除法
- 下一篇: 1056. 组合数的和(15)