how do i make an invisible text input box visible on hover?

流过昼夜 提交于 2019-12-12 06:22:40

问题


It doesn't seem to work for me!

HTML

 <div id="box1">
     <form action="">
         <input type="string" name="htmlcode" />
     </form>
 </div>

CSS

#box1 {
    width:100px;
    height:100px;
    border-color:black 4px
}
input {
    display:none;
}
a:hover input{
    display:block;
}

the text input is either invisible, or visible but does not respond to hover


回答1:


You don't have an a tag that you can hover to show the input...

Change it to #box1:hover input{display:block;} so it will show when you move your mouse into the box.

border-color:black 4px is also invalid. If you want to set the border color, you can only give it a color, not a color and size.

Here's a demo showing both of those things fixed.




回答2:


You don't have <a> in html. Try: div:hover input{display:block;}




回答3:


 #box1 { 
    width:100px;
    height:100px;
    border:4px solid black;
}
 input {display:none;}
 #box1:hover input{display:block;}​

As others mentioned, you don't have an a tag so change the target of the :hover as well.

Also fixed the border declaration.

http://jsfiddle.net/XZvHh/




回答4:


in your css you need to add this

#box1:hover input{display:block;}


来源:https://stackoverflow.com/questions/11869805/how-do-i-make-an-invisible-text-input-box-visible-on-hover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!