隐藏 HTML 元素,使其不占用任何空间

发布于 2024-12-28 15:40:05 字数 412 浏览 2 评论 0原文

有人可以解释一下如何修改下面显示的第二个输入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

转身泪倾城 2025-01-04 15:40:05

使用display: none;,如图:

<input id="county_no" type="text" value="" disabled="disabled" style="display: none;" />

参考:

Use display: none;, as shown:

<input id="county_no" type="text" value="" disabled="disabled" style="display: none;" />

Reference:

柳絮泡泡 2025-01-04 15:40:05
display:none in stead of visibility:hidden
display:none in stead of visibility:hidden
扭转时空 2025-01-04 15:40:05

使用 style="display:none;" 而不是 visibility:hidden

visibility:hidden 留出空间。

Use the style="display:none;" instead of visibility:hidden

visibility:hidden leaves space.

∝单色的世界 2025-01-04 15:40:05

您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文