scss Sass mixin用于使表格响应
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss Sass mixin用于使表格响应相关的知识,希望对你有一定的参考价值。
@mixin responsive-table($thead-title...) {
table {
width: 100%;
border-collapse: collapse;
}
@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;
}
@for $i from 1 through length($thead-title) {
td:nth-of-type(#{$i}):before {
content: nth($thead-title, $i);
}
}
}
}
/*Usage example*/
.table-container {
/*Write thead titles here*/
@include responsive-table(
'Name',
'Last Name',
'Username',
'Age',
'Gender',
);
}
以上是关于scss Sass mixin用于使表格响应的主要内容,如果未能解决你的问题,请参考以下文章
scss 响应型Mixin for Sass,取自postcss-responsive-typography
scss 用于媒体查询的Sass mixins
scss 用于项目Mixin零件的SASS样板
scss 方便的sass mixin用于媒体查询
scss Sass mixin用于快速应用clearfix
scss #sass我的一些用于SASS / Compass的goto mixins