我已经构建了一个HTML表格,您可以在此处看到:Go Free Bet
桌子在移动设备上显示得不是很好。所以,我发现这个CSS使表格响应。
然而,当我添加时我添加了CSS,而桌面和移动设备上的桌子看起来都很棒(hallelujah!),它仍然显示所有我的标题,堆叠成黑色的行在桌子的顶部。
我确信这是我缺少的一些东西,因为我没有使用过代码。任何帮助都将非常感激!
非常感谢, HJF
/*Generic Styling, for Desktops/Laptops*/
table {
width: 100%;
border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: left;
}
/*
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: 760px),
(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 { border: 1px solid #ccc; }
td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*
Label the data
*/
td:nth-of-type(1):before { content: "First Name"; }
td:nth-of-type(2):before { content: "Last Name"; }
td:nth-of-type(3):before { content: "Job Title"; }
td:nth-of-type(4):before { content: "Favorite Color"; }
td:nth-of-type(5):before { content: "Wars of Trek?"; }
td:nth-of-type(6):before { content: "Porn Name"; }
td:nth-of-type(7):before { content: "Date of Birth"; }
td:nth-of-type(8):before { content: "Dream Vacation City"; }
td:nth-of-type(9):before { content: "GPA"; }
td:nth-of-type(10):before { content: "Arbitrary Data"; }
}`/*
答案 0 :(得分:0)
我建议你使用w3 css style sheet .. 所以玩w3 css的div类吧..
例如,如果你想在小屏幕尺寸上隐藏div,你只需要添加类
W3隐藏小
在你的div或你的桌子里.. 我想
显示:阻止
不适用于表元素