Php 移动友好数据表
我想做一个移动友好的桌子。我已经将表格的格式在某个像素值处更改为列表。然而,当你打电话时,标题与数据冲突 在mobile中,表格如下所示: 我只想能够打破标题,使部分的冲突只是包装到一个新的线Php 移动友好数据表,php,html,html-table,Php,Html,Html Table,我想做一个移动友好的桌子。我已经将表格的格式在某个像素值处更改为列表。然而,当你打电话时,标题与数据冲突 在mobile中,表格如下所示: 我只想能够打破标题,使部分的冲突只是包装到一个新的线 <style> td { word-wrap: break-word; } /* Max width before this PARTICULAR table gets nasty. This query will ta
<style>
td {
word-wrap: break-word;
}
/*
Max width before this PARTICULAR table gets nasty. This query will take effect for any screen smaller than 760px and also iPads specifically.
*/
@media
only screen
and (max-width: 1500px), (min-device-width: 768px)
and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr {
margin: 0 0 1rem 0;
}
tr:nth-child(odd) {
background: #ccc;
}
td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
word-wrap: break-word;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 0;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*
Label the data
You could also use a data-* attribute and content for this. That way "bloats" the HTML, this way means you need to keep HTML and CSS in sync. Lea Verou has a clever way to handle with text-shadow.
*/
td:nth-of-type(1):before { content: "Date"; }
td:nth-of-type(2):before { content: "Time"; }
td:nth-of-type(3):before { content: "Aircraft"; }
td:nth-of-type(4):before { content: "Passenger"; }
td:nth-of-type(5):before { content: "Instructor"; }
td:nth-of-type(6):before { content: "Fuel"; }
td:nth-of-type(7):before { content: "Landings"; }
td:nth-of-type(8):before { content: "Starting Tacho"; }
td:nth-of-type(9):before { content: "Finishing Tacho"; }
td:nth-of-type(10):before { content: "Flight Time"; }
td:nth-of-type(11):before { content: "Aircraft Fees ($)"; }
td:nth-of-type(12):before { content: "Instructor Fees ($)"; }
td:nth-of-type(13):before { content: "GST ($)"; }
td:nth-of-type(14):before { content: "Total Cost ($)"; }
}
</style>
运输署{
单词包装:打断单词;
}
/*
在这张桌子变脏之前的最大宽度。此查询将对小于760像素的任何屏幕生效,尤其是iPad。
*/
@媒体
唯一屏幕
和(最大宽度:1500px),(最小设备宽度:768px)
和(最大设备宽度:1024px){
/*强制表不再像表一样*/
表,THAD,tbody,th,td,tr{
显示:块;
}
/*隐藏表格标题(但不显示:none;,用于辅助功能)*/
thead tr{
位置:绝对位置;
顶部:-9999px;
左:-9999px;
}
tr{
保证金:0.01雷姆0;
}
tr:n个孩子(奇数){
背景:#ccc;
}
运输署{
/*表现得像“一排”*/
边界:无;
边框底部:1px实心#eee;
位置:相对位置;
左:50%;
单词包装:打断单词;
}
td:之前{
/*现在就像一个表格标题*/
位置:绝对位置;
/*上/左值模拟填充*/
排名:0;
左:6px;
宽度:45%;
右边填充:10px;
空白:nowrap;
}
/*
标记数据
你也可以使用data-*属性和内容来实现这一点。这样“膨胀”HTML,这意味着你需要保持HTML和CSS的同步。Lea Verou有一种巧妙的方法来处理文本阴影。
*/
td:n类型(1):在{内容:“日期”;}之前
td:n类型(2):在{content:“Time”;}之前
td:n第(3)类:{内容:“飞机”;}
td:n类型(4):在{内容:“乘客”;}之前
td:n类型(5):在{内容:“讲师”;}之前
td:n类型(6):在{内容:“燃料”;}之前
td:n类型(7):在{内容:“着陆”}之前
td:n类型(8):在{内容:“开始测速”}之前
td:n类型(9):在{内容:“完成测速”}之前
td:n类型(10):在{内容:“飞行时间”;}之前
td:n类型(11):在{内容:“飞机费用($)”;}之前
td:n类型(12):在{内容:“讲师费用($)”;}之前
td:n类型(13):在{内容:“GST($)”;}之前
td:n类型(14):在{content:“总成本($)”;}之前
}
用这种方法
将您的需求基础更改为断点
@media screen and (max-width: 640px) {}
var headertext = [],
headers = document.querySelectorAll("#customDataTable th"),
tablerows = document.querySelectorAll("#customDataTable th"),
tablebody = document.querySelector("#customDataTable tbody");
for (var i = 0; i < headers.length; i++) {
var current = headers[i];
headertext.push(current.textContent.replace(/\r?\n|\r/, ""));
}
for (var i = 0, row; row = tablebody.rows[i]; i++) {
for (var j = 0, col; col = row.cells[j]; j++) {
col.setAttribute("data-th", headertext[j]);
}
}
#
名字
姓氏
年龄
城市
国家
1.
安娜
皮特
35
纽约
美国
1.
安娜
皮特
35
纽约
美国
用这种方法
将您的需求基础更改为断点
@media screen and (max-width: 640px) {}
var headertext = [],
headers = document.querySelectorAll("#customDataTable th"),
tablerows = document.querySelectorAll("#customDataTable th"),
tablebody = document.querySelector("#customDataTable tbody");
for (var i = 0; i < headers.length; i++) {
var current = headers[i];
headertext.push(current.textContent.replace(/\r?\n|\r/, ""));
}
for (var i = 0, row; row = tablebody.rows[i]; i++) {
for (var j = 0, col; col = row.cells[j]; j++) {
col.setAttribute("data-th", headertext[j]);
}
}
#
名字
姓氏
年龄
城市
国家
1.
安娜
皮特
35
纽约
美国
1.
安娜
皮特
35
纽约
美国
此处存在客户端问题,请显示客户端代码。这里没有人可以使用您的服务器端设置或数据来创建一个合适的示例。话虽如此,您可能想过度考虑使用空白:nowrap
您在这里遇到了客户端问题,因此请显示客户端代码。这里没有人可以使用您的服务器端设置或数据来创建一个合适的示例。话虽如此,您可能想过度考虑使用空白:nowrap
非常感谢您的解决方案。。一个小问题。。该表不会在apple设备上重新格式化。。在windows和Andriod上运行良好非常感谢您的解决方案。。一个小问题。。该表不会在apple设备上重新格式化。。在windows和andriod上工作正常