隐藏 HTML 元素,使其不占用任何空间
有人可以解释一下如何修改下面显示的第二个输入 ID,使其在页面上不可见并且不占用页面上的任何空间吗?
<section>
<label for="muni">Municipality</label>
<div>
<input id="county_select" type="text" />
<input id="county_no" type="text" value="" disabled="disabled" style="visibility:hidden" />
</div>
</section>
目前,第二个输入 id 占用了我表单上的空间,我不希望它占用任何空间。谢谢。
Can someone explain how I can modify the second input id shown below so that it is not visible on the page and also does not take up any space on the page?
<section>
<label for="muni">Municipality</label>
<div>
<input id="county_select" type="text" />
<input id="county_no" type="text" value="" disabled="disabled" style="visibility:hidden" />
</div>
</section>
Currently, this second input id takes up space on my form and I don't want it to take up any space. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
display: none;
,如图:参考:
显示
属性。Use
display: none;
, as shown:Reference:
display
property.使用
style="display:none;"
而不是visibility:hidden
visibility:hidden
留出空间。Use the
style="display:none;"
instead ofvisibility:hidden
visibility:hidden
leaves space.您可以使用 CSS 设置输入样式,并通过其
id
标记来定位它。在您的
.css
文件中:#county_no
{显示:无;
}
应避免 HTML 内联样式。
You can style the input using CSS, targeting it via its
id
tag.In your
.css
file:#county_no
{display: none;
}
Styling HTML inline should be avoided.