css - html table with vertical scroll inside tbody -
i trying vertical scroll bar inside tbody fixed header. tried solution provided in link.
html table 100% width, vertical scroll inside tbody
table { width: 100%; border-spacing: 0; } thead, tbody, tr, th, td { display: block; } thead tr { /* fallback */ width: 97%; /* minus scroll bar width */ width: -webkit-calc(100% - 16px); width: -moz-calc(100% - 16px); width: calc(100% - 16px); } tr:after { /* clearing float */ content: ' '; display: block; visibility: hidden; clear: both; } tbody { height: 100px; overflow-y: auto; overflow-x: hidden; } tbody td, thead th { width: 19%; /* 19% less (100% / 5 cols) = 20% */ float: left; }
it works fine if scroll bar appears.but if rows few , scroll bar doesn't appear, thead not aligned tbody. how can fix issue css?
once tbody data move-out assigned height, y-axis get's activated.
tbody { height: 50px; display: inline-block; width: 100%; overflow-y:scroll; }
Comments
Post a Comment