Html input[type=hidden] 和visibility="hidden" 之间的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18674912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 13:07:42  来源:igfitidea点击:

difference between input[type=hidden] and visibility="hidden"

htmlcss

提问by meee meeee

What's the difference between input[type=hidden]and visibility : hidden;?

input[type=hidden]和 和有visibility : hidden;什么区别?

回答by Rahul Tripathi

The first one is input element and the second is used for style in CSS2.

第一个是输入元素,第二个用于 CSS2 中的样式。

visibility: hidden;The visibility property specifies whether or not an element is visible.

visibility: hidden;可见性属性指定元素是否可见。

input[type=hidden]:- HIDDEN is a TYPE attribute value to the INPUT element for FORMs. It indicates a form field that does not appear visibly in the document and that the user does not interact with. It can be used to transmit state information about the client or server.

input[type=hidden]:- HIDDEN 是表单的 INPUT 元素的 TYPE 属性值。它表示在文档中不可见且用户不与之交互的表单域。它可用于传输有关客户端或服务器的状态信息。

回答by Phillip Berger

I'm assuming you mean what is the difference between <input type="hidden" />and with CSS

我假设您的意思是<input type="hidden" />CSS 和 CSS之间的区别

.hidden {
    display: none;
}

If that's the case then the first one is a DOM type but still in the structure, the second is a style method to remove the item from the DOM structure.

如果是这种情况,那么第一个是 DOM 类型但仍在结构中,第二个是从 DOM 结构中删除项目的样式方法。

回答by David

input[type=hidden]

This is a DOM selector (jQuery, CSS, etc.) for any inputelements where the typeattribute is "hidden". It doesn't have anything to do with actually displaying or hiding those elements, aside from the fact that browsers don't render <input type="hidden" />elements.

这是属性为 的任何input元素的 DOM 选择器(jQuery、CSS 等)。除了浏览器不渲染元素这一事实之外,它与实际显示或隐藏这些元素没有任何关系。type"hidden"<input type="hidden" />

visibility="hidden"

This is setting the CSS visibilitypropertyto the value "hidden" which would tell the browser to not render whatever element(s) to which you're applying that attribute. This is entirely about display of HTML elements and doesn't have anything to do with selectors or form elements as the other example does.

这是将CSSvisibility属性设置为值“隐藏”,这将告诉浏览器不要呈现您正在应用该属性的任何元素。这完全是关于 HTML 元素的显示,与其他示例中的选择器或表单元素没有任何关系。

回答by MarcinJuraszek

input[type=hidden]is definitely a selector, which matches every inputelement which has typeattribute value set to hidden.

input[type=hidden]绝对是一个选择器,它匹配每个属性值设置为 的input元素。typehidden

I have no idea what visibility="hidden"is. It couldbe CSS property, but incorrect one. It should be visibility: hidden;to be valid.

我不知道是什么visibility="hidden"。它可能是 CSS 属性,但不正确。它应该visibility: hidden;是有效的。