html - Adjust width of td with rotated headers -
i have table uses javascript show or hide columns. column headers rotated 90 degrees.
everything works functionally, there 1 issue haven't been able figure out. width of columns should 20px. appears width of column equal of div before rotated.
i have tried adjusting width of div inside tds 20px. in case width of column correctly adjusts 20px, header text appears cut off. i've tried compensating via setting overflow: visible; when columns visible, appears change actual position of header divs. idea how can working?
here code (background colors added visualize position of div relative td).
function showhidematrix() { var privcells = document.getelementsbyclassname('privcol'); var privmatrixcells = document.getelementsbyclassname('privmatrixcol'); (var = 0, ilen = privcells.length; < ilen; i++) { if (privcells[i].style.height === '' || privcells[i].style.height != '0px') { privcells[i].style.height = '0px'; privcells[i].style.width = '0px'; } else { if(privcells[i].classname.indexof('privhead') > -1){ privcells[i].style.height = '20px'; privcells[i].style.width = '150px'; } else { privcells[i].style.height = '20px'; privcells[i].style.width = '20px'; } } } (var j = 0, ilen1 = privmatrixcells.length; j < ilen1; j++) { if (privmatrixcells[j].style.height === '' || privmatrixcells[j].style.height == '0px') { if(privmatrixcells[j].classname.indexof('privhead') > -1){ privmatrixcells[j].style.height = '20px'; privmatrixcells[j].style.width = '150px'; } else { privmatrixcells[j].style.height = '20px'; privmatrixcells[j].style.width = '20px'; } } else { privmatrixcells[j].style.height = '0px'; privmatrixcells[j].style.width = '0px'; } } }
.privhead { /* rotation */ -ms-transform: rotate(90deg); /* ie9+ */ -webkit-transform: rotate(90deg); /* safari 3.1+, chrome */ -moz-transform: rotate(90deg); /* ff3.5+ */ -o-transform: rotate(90deg); /* opera 10.5 */ transform: rotate(90.0deg); /* standard */ filter: progid:dximagetransform.microsoft.basicimage(rotation=0.083); /* ie6,ie7 */ -ms-filter:"progid:dximagetransform.microsoft.basicimage(rotation=0.083)"; /* ie8 */ //transform-origin: center center; /* text */ overflow: hidden; font-family: verdana, arial, helvetica; font-size: 10pt; font-weight: bold; //height: 20px; width: 150px; text-align: left; //position: relative; } .privcol { /* transition */ -webkit-transition: 0.8s; -moz-transition: 0.8s; -o-transition: 0.8s; -ms-transition: 0.8s; transition: 0.8s; vertical-align: bottom; text-align: left; overflow: hidden; } .privmatrixcol { /* transition */ -webkit-transition: 0.8s; -moz-transition: 0.8s; -o-transition: 0.8s; -ms-transition: 0.8s; transition: 0.8s; width: 0px; overflow: hidden; margin: auto; } .privtext{ width: 100%; } table{ width: 400px; } table, tr, td { border: 1px solid black; border-collapse: collapse; padding: 0; border-spacing: 0px; }
<table id="table0" style="margin-top: 100px;"> <thead> <tr> <td colspan="4"> <button onclick="showhidematrix()" href="">matrix</button> </td> </tr> </thead> <tbody id="body0"> <tr> <td style="background-color: lightblue; height: 150px;"> <div class="privhead privcol" style="background-color: lightgreen; width: 150px; position: relative;">request</div> </td> <td style="background-color: lightblue; height: 150px;"> <div class="privhead privcol" style="background-color: lightgreen; position: relative;">recommend</div> </td> <td style="background-color: lightblue; height: 150px; width: 0px;"> <div class="privhead privmatrixcol" style="background-color: lightgreen;">demo</div> </td> <td></td> </tr> <tr> <td> <div class="privcol" style="text-align: center;"> <input type="checkbox" checked="checked" /> </div> </td> <td> <div class="privcol" style="text-align: center;"> <input type="checkbox" /> </div> </td> <td> <div class="privmatrixcol" style="text-align: center;">•</div> </td> <td> <div class="privtext">priv 2</div> </td> </tr> </tbody> </table>
Comments
Post a Comment