css实现自适应响应式表格table效果代码
代码语言:html
所属分类:响应式
代码描述:css实现自适应响应式表格table效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { font: 90%/1.4 system-ui; margin: 0; font-family: sans-serif; } header { padding: 7vh 5vw; border-bottom: 1px solid #ddd; } header h1, header p { margin: 0; } footer { padding: 7vh 5vw; border-top: 1px solid #ddd; } aside { padding: 7vh 5vw; } .primary { overflow: auto; scroll-snap-type: x mandatory; height: 80vh; } @media (min-width: 40em) { main { display: flex; } aside { flex: 0 1 20vw; order: 1; border-right: 1px solid #ddd; } .primary { order: 2; } } table { border-collapse: collapse; border: 0; } th, td { border: 1px solid #aaa; background-clip: padding-box; scroll-snap-align: start; } tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; } thead { z-index: 1000; position: relative; } th, td { padding: 0.6rem; min-width: 6rem; text-align: left; margin: 0; } thead th { position: sticky; top: 0; border-top: 0; background-clip: padding-box; } thead th.pin { left: 0; z-index: 1001; border-left: 0; } tbody th { background-clip: padding-box; border-left: 0; } tbody { z-index: 10; position: relative; } tbody th { position: sticky; left: 0; } thead th, tbody th { background-color: #f8f8f8; } </style> </head> <body > <main> <section class="primary"> <table> <thead> <tr> <th class="pin"> </th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> <th>Col Header</th> </tr> </thead> <tbody> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> </tr> <tr> <th>Row Header</th> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td> <td>Cell Data</td>.........完整代码请登录后点击上方下载按钮下载查看
网友评论0