How can I hide an HTML table row so that it takes up no space?

前端 未结 15 987
情歌与酒
情歌与酒 2020-12-25 09:15

How can I hide an HTML table row so that it takes up no space? I have several \'s set to style=\"display:none;\"

相关标签:
15条回答
  • 2020-12-25 09:38

    You need to put the change the input type to hidden, all the functions of it work but it is not visible on the page

    <input type="hidden" name="" id="" value="">
    

    as long as the input type is set to that you can change the rest. Good Luck!!

    0 讨论(0)
  • 2020-12-25 09:40

    position: absolute will remove it from the layout flow and should solve your problem - the element will remain in the DOM but won't affect others.

    0 讨论(0)
  • 2020-12-25 09:43

    You can use style display:none with tr to hide and it will work with all browsers.

    0 讨论(0)
  • 2020-12-25 09:51

    HTML:

    <input type="checkbox" id="attraction" checked="checked" onchange="updateMap()">poi.attraction</input>
    

    JavaScript:

    function updateMap() {
         map.setOptions({'styles': getStyles() });
    } 
    
    function getStyles() {
        var styles = [];
        for (var i=0; i < types.length; i++) {
          var style = {};
          var type = types[i];
          var enabled = document.getElementById(type).checked;
          style['featureType'] = 'poi.' + type;
          style['elementType'] = 'labels';
          style['stylers'] = [{'visibility' : (enabled ? 'on' : 'off') }];
          styles.push(style);
        }
        return styles;
    }
    
    0 讨论(0)
  • 2020-12-25 09:52

    You can set <tr id="result_tr" style="display: none;"> and then show it back with JavaScript:

    var result_style = document.getElementById('result_tr').style;
    result_style.display = 'table-row';
    
    0 讨论(0)
  • 2020-12-25 09:53

    Thought I'd add to this a potential other solution:

    <tr style='visibility:collapse'><td>stuff</td></tr>

    I've only tested it on Chrome but putting this on the <tr> hides the row PLUS all the cells inside the row still contribute to the widths of the columns. I will sometimes make an extra row at the bottom of a table with just some spacers that make it so certain columns can't be less than a certain width, then hide the row using this method. (I know you're supposed to be able to do this with other css but I've never gotten that to work)

    Again, I'm in a purely chrome environment so I have no idea how this functions in other browsers.

    0 讨论(0)
提交回复
热议问题