gpt4 book ai didi

css - 如何使表响应类名?

转载 作者:太空宇宙 更新时间:2023-11-04 02:42:43 25 4
gpt4 key购买 nike

我有这个媒体:

@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;
}

}

此媒体影响所有 table 元素。现在我怎样才能在我想要的 table 上使用这个媒体?

最佳答案

为您想要的表添加类或 ID。例如,我将 class="test" 添加到您想要的表中。你的 CSS 是这样的

@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px) {

/* Force table to not be like tables anymore */
.test, .test thead, .test tbody, .test th, .test td, .test tr {
display: block;
}

/* Hide table headers (but not display: none;, for accessibility) */
.test thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}

.test tr { border: 1px solid #ccc; }

.test td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}

.test 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;
}

}

关于css - 如何使表响应类名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34411104/

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