I have the following piece of HTML with effectively a table for an aligned form:
<div id="one">
<p>
<label for="a">a</label> <input type="text" id="a">
</p>
<p class="h">
<label for="b">bbbbbb</label> <input type="text" id="b">
</p>
</div>
with the following CSS:
#one {
display: table;
width: auto;
}
p {
display: table-row;
}
p label, p input {
display: table-cell;
}
#one is something of automatically computed width, and labels and inputs are of unknown width. I want the functionality of an aligned form, but such that adding class h to their row removes then, making space for other elements vertically, but not changing width of #one, since it is supposed to sit next to other elements with automatically computed width.
What .h definition in CSS3 would give me my "table row" (p) height equal to 0 or otherwise visually remove it without changing the width of its parent? I can change HTML if needed, but I want to find a solution that does not use JS for that.
visibility: hidden does not remove it vertically, height: 0 does not work (probably because it is table-row), and display: none does not work, because it changes the effective width to 0. And I want my #one to stay the same width. Using display: block !important in combination with height: 0 partially works, but leaves a weird vertical space (and block should not really be a child of table).
What I'm searching for is similar to this SO question, but I'm searching for a pure CSS solution and without fixing the table width.
You can play with it here: JSFiddle.