作者:美女牙医--妙菡众 | 来源:互联网 | 2023-09-07 17:35
Iwanttheplaceholdertomovetothetopwhenthetextboxisonfocusandalsowhiletheuseristy
I want the placeholder to move to the top when the textbox is on focus and also while the user is typing.
我希望占位符在文本框处于焦点时以及用户键入时移动到顶部。
I'm not sure if this is just html/css or any Javascript too.
我不确定这只是html / css还是任何Javascript。
My current css looks like this, and I have no js code yet:
我当前的CSS看起来像这样,我还没有js代码:
input:focus::-webkit-input-placeholder {
font-size: .75em;
position: relative;
top: -15px;
transition: 0.2s ease-out;
}
input::-webkit-input-placeholder {
transition: 0.2s ease-in;
}
input[type="text"]:focus, input[type="password"]:focus {
height: 50px;
padding-bottom: 0px;
transition: 0.2s ease-in;
}
input[type="text"], input[type="password"] {
height: 50px;
transition: 0.2s ease-in;
}
It almost does the work (isn't as perfect as the link), but the placeholder disappears when I start typing. I'm using twitter-bootstrap, if that makes anything easier!
它几乎完成了工作(不如链接那么完美),但是当我开始输入时占位符消失了。我正在使用twitter-bootstrap,如果这更容易!
Thanks.
谢谢。
4 个解决方案