javascript - Trying to make fixed table header in HTML, scroll and visibility issues? -
i have been trying make table in html fixed header (and horizontal scrollbar when necessary). jsfiddle shows have far:
html, body { margin:0; padding:0; height:100%; } .horizontalscrollcontainer { position: relative; padding-top: 37px; overflow:auto; } .verticalscrollcontainer { background:transparent; overflow-y:auto; overflow-x:visible; height: 200px; } table { border-spacing: 0; width:120%; } td + td { border-left:1px solid #eee; } td, th { border-bottom:1px solid #eee; background: #ddd; color: black; padding: 10px 25px; } th { height: 0; line-height: 0; padding-top: 0; padding-bottom: 0; color: transparent; border: none; white-space: nowrap; } th div { position: absolute; background: transparent; color: black; padding: 9px 25px; top: 0px; margin-left: -25px; line-height: normal; border-left: 1px solid #800; } th:first-child div { border: none; } <div class="horizontalscrollcontainer"> <div class="verticalscrollcontainer"> <table> <thead> <tr class="header"> <th>table attribute name <div>table attribute name</div> </th> <th>value <div>value</div> </th> <th>description <div>description</div> </th> </tr> </thead> <tbody> <tr> <td>align</td> <td>left, center, right</td> <td>not supported in html5. deprecated in html 4.01. specifies alignment of table according surrounding text</td> </tr> <tr> <td>bgcolor</td> <td>rgb(x,x,x), #xxxxxx, colorname</td> <td>not supported in html5. deprecated in html 4.01. specifies background color table</td> </tr> <tr> <td>border</td> <td>1,""</td> <td>specifies whether table cells should have borders or not</td> </tr> <tr> <td>cellpadding</td> <td>pixels</td> <td>not supported in html5. specifies space between cell wall , cell content</td> </tr> <tr> <td>cellspacing</td> <td>pixels</td> <td>not supported in html5. specifies space between cells</td> </tr> <tr> <td>frame</td> <td>void, above, below, hsides, lhs, rhs, vsides, box, border</td> <td>not supported in html5. specifies parts of outside borders should visible</td> </tr> <tr> <td>rules</td> <td>none, groups, rows, cols, all</td> <td>not supported in html5. specifies parts of inside borders should visible</td> </tr> <tr> <td>summary</td> <td>text</td> <td>not supported in html5. specifies summary of content of table</td> </tr> <tr> <td>width</td> <td>pixels, %</td> <td>not supported in html5. specifies width of table</td> </tr> </tbody> </table> </div> </div>
https://jsfiddle.net/byb9d/6248/
the problem having horizontal scrollbar seems go on verticalscrollcontainer rather horizontalscrollcontainer. there way regulate (the overflow-x automatically set auto because overflow-y set auto).
thanks suggestions!
Comments
Post a Comment