CSS3制作响应式表格

CSS3制作响应式表格

添加时间:2021-02-19 12:48:44
站长推荐丨赞助论坛,可获取海量资源终身免费下载权限奥!
举报 举报
收藏
预览
附件 附件
  • 模板类型模板类型:table
  • 模板颜色模板颜色:中级
  • 下载积分下载积分:28 米粒
  • 下载权限下载权限:

    赞助会员

本文以实例演示如何使用css3来制作漂亮的响应式表格效果。
CSS3制作响应式表格
分类:css3 > table 难易:中级

HTML

<table>
    <thead>
        <tr>
            <th>姓名</th>
            <th>性别</th>
            <th>出生年月</th>
            <th>班级</th>
            <th>语文</th>
            <th>数学</th>
            <th>外语</th>
            <th>综合</th>
            <th>总分</th>
            <th>名次</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>蒋介</td>
            <td>男</td>
            <td>1998.2.5</td>
            <td>H123</td>
            <td>98</td>
            <td>126</td>
            <td>92</td>
            <td>215</td>
            <td>531</td>
            <td>156</td>
        </tr>
    </tbody>
</table>

CSS

table {
	width: 100%;
	border-collapse: collapse;
	background:#fff
}
/* 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;
}
@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: "姓名";
}
td:nth-of-type(2):before {
	content: "性别";
}
td:nth-of-type(3):before {
	content: "出生年月";
}
td:nth-of-type(4):before {
	content: "班级";
}
td:nth-of-type(5):before {
	content: "语文";
}
td:nth-of-type(6):before {
	content: "数学";
}
td:nth-of-type(7):before {
	content: "外语";
}
td:nth-of-type(8):before {
	content: "综合";
}
td:nth-of-type(9):before {
	content: "总分";
}
td:nth-of-type(10):before {
	content: "名次";
}
} 
/* Smartphones (portrait and landscape) -----------*/
	@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
	body {
	padding: 0;
	margin: 0;
}
} 
/* iPads (portrait and landscape) -----------*/
	@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
	body {
	width: 100%;
}
}
相关内容推荐
资源求助发帖
查看更多发帖

*

回帖描述:

*

链接类型:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
热点内容推荐
标题:CSS3制作响应式表格

*

描述:
平均回复时间:3-10分钟
规则介绍:悬赏寻求论坛网友分享资源,站点对分享内容的准确性,合法性,版权等没有足够的监管能力。如果您发现资源不正确,无法使用,不符合法律法律等情况,您可以直接举报资源。站长将尽快核实您的举报,并根据情况,采取封号,退换米粒等处理。

*

回帖描述:

*

链接类型:

*

阅读权限:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
  • 背景波浪
  • 背景波浪
  • 波浪
  • 波浪
客服
在线咨询
周一 至 周日 9:00 ~ 22:00
QQ:1326974360
微信:juyoubuluo6688
客服热线
18205485173
工作日 9:00 ~ 18:00
微信扫码咨询
客户服务
欢迎咨询服务
咨询量较多时,请耐心等待
社群

关注公众号

获取更多资讯

扫码进群(QQ)

与更多大牛交流沟通

0.208194s