如果我想隐藏我的文本区域,我该怎么做?
最佳答案
每个人都在给你答案,但原因不多。给你:如果你使用 CSS 规则 visibility:hidden;
文本区域将不可见,但它仍然会占用空间。如果您使用 CSS 规则 display:none;
textarea 将被隐藏并且它不会在屏幕上保留空间 - 没有间隙,换句话说,它会在哪里已经。下面的可视化示例。
所以你希望这样的东西完全隐藏:
<textarea cols="20" rows="20" style="display:none;">
例子
/* no styling should show up for either method */
textarea {
background: lightblue;
border: 1px solid blue;
font-weight: bold;
}
<p><strong>Textarea (not hidden)</strong></p>
<textarea>Text within.</textarea>
<p>Some text after.</p>
<hr />
<p><strong>Textarea with <code>display:none;</code></strong></p>
<textarea style="display:none;">Text within.</textarea>
<p>Some text after. Neither height nor margin/padding/layout kept. No other styles visible.</p>
<hr />
<p><strong>Textarea with <code>visibility:hidden;</code></strong></p>
<textarea style="visibility:hidden;">Text within.</textarea>
<p>Some text after. Height and margin/padding/layout kept. No other styles visible.</p>
关于html - 如果我想隐藏我的文本区域,我该怎么做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2362498/