gpt4 book ai didi

css - 在 HTML 表格中隐藏移动设备上除一个标题以外的所有标题

转载 作者:行者123 更新时间:2023-11-28 02:12:01 25 4
gpt4 key购买 nike

我已经构建了一个 HTML 表格,您可以在这里看到:Go Free Bet

并且该表格在移动设备上的显示效果不佳。所以,我找到了这个 CSS 来使表格响应。

但是,当我添加 CSS 时,虽然表格在桌面和移动设备上看起来都很棒(hallelujah!),但它仍然显示所有我的标题,堆叠成黑色行在表格的顶部。

我确信这是我缺少的一些基本知识,因为我完全没有使用代码的经验。任何帮助将不胜感激!

非常感谢,海锦峰

/*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"; }
}`/*

最佳答案

我建议你使用 w3 css style sheet ..所以玩一下 w3 css 的 div 类..

例如,如果你想在小屏幕上隐藏 div,你只需要添加类

w3-hide-small

在你的 div 或你的表格中..我觉得

display: block

不适用于表格元素

关于css - 在 HTML 表格中隐藏移动设备上除一个标题以外的所有标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48695925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com