How do you make Placeholder and Label Transitions?

后端 未结 2 1534
迷失自我
迷失自我 2020-12-10 09:59

I am looking to find an example of how to make a label / placeholder transition move up and out of placeholder position into a label position and vice versa..

Exam

2条回答
  •  情深已故
    2020-12-10 10:38

    General sibling selectors & :focus does the trick in a very simple way ;)

    input{
     position:absolute;
     top:20px;
    }
    input ~ span{
     transition:top .7s ease;
     position:absolute;
     top:20px;
    }
    input:focus ~ span{
     top:0px;
    }

    here is an example with multiple fields

    https://jsfiddle.net/shLe3107/1/

    hope this is enough else just ask

提交回复
热议问题