我在一个表格单元格中有一个 div,其 css 值为 display:none。当我 $.show() 它时,单元格会稍微向右扩展。当我使用可见属性而不是 display:none 时,这可以正常工作,但如果不需要,我不想保留高度。我尝试了各种显示属性以及重新排列 css 宽度、边距和填充,以及删除背景图像。
<div id='1'>
<table>
<tr>
<td>
<div class='container'>
<div class='error'>I am some long ass error that breaks my layout and I can't figure out what to do.</div>
<div>header</div>
<div>
<input type='button' value='add to cart'/>
</div>
</div>
</td>
<td>
<div class='container'>
<div class='error'>I am some long ass error that breaks my layout and I can't figure out what to do.</div>
<div>header</div>
<div>
<input type='button' value='add to cart'/>
</div>
</div>
</td>
<td>
<div class='container'>
<div class='error'>I am some long ass error that breaks my layout and I can't figure out what to do.</div>
<div>header</div>
<div>
<input type='button' value='add to cart'/>
</div>
</div>
</td>
</tr>
</table>
</div>
#1{width:400px;}
table {width:100%;}
tr {border: solid grey;}
.container{
border-right: 1px dotted #A5A5A5;
margin: 25px 0;
}
div {
display:block;
margin:auto;
text-align:center;
}
.error {
display:none;
padding-left:20px;
width:80px;
table-layout:fixed;
}
这是一个显示问题的小提琴