how do i make an invisible text input box visible

2019-08-26 01:08发布

问题:

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;}