通过CSS使输入不可见

通过CSS使输入不可见

本文介绍了通过CSS使输入不可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,根据网站的品牌,应该在一个给定位置显示两个输入字段之一.

I have a form where depending on the website's brand one of two input fields should be visible at one given spot.

我想我只是将两个输入字段放在同一个容器中,然后通过样式表将其中一个输入字段设置为display:none;.这确实隐藏了字段,但是仍然占用了空间.我还尝试将高度和宽度设置为0或将可见性设置为隐藏或折叠,但是这些都不起作用.

I figured I just put both input fields in the same container and then through my stylesheet set one of them to display:none;This does hide the field, but it still makes it take up space.I also tried setting the height and width to 0 or setting visibility to hidden or collapse but none of those worked.

直到现在所有的品牌化工作都可以通过CSS样式表完成,所以我想保持这种方式.该解决方案至少应在IE6和更高版本中得到支持. Firefox 2和更高版本和最新版本的Chrome.

Untill now all the branding things could be done with css style sheets so I would like to keep it that way.The solution should at least be supported in IE6 & up, Firefox 2 & up and Chrome (latest).

推荐答案

将不可见的输入字段设置为position: absolute;会将其从渲染流程中删除的情况如何?

What about setting the invisible input field to position: absolute; which should take it out of the rendering flow.

但是,将其设置为display: none从理论上讲应该做同样的事情...

However, setting it to display: none should in theory do the same...

这篇关于通过CSS使输入不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 08:28