简体   繁体   English

使 <input /> 出现在过渡 <div>

[英]Make <input /> appear on transitioning <div>

I have this setup: 我有这个设置:

 .wrapper { height: 40px; width: 80px; border-style: solid; border-width: 2px; border-radius: 40px; border-color: red; display: flex; align-items: center; justify-content: center; } .element { background-color: hotpink; width: 10px; height: 10px; } .wrapper:hover { width: 800px; -webkit-transition: width 0.4s ease-in-out; justify-content: left; padding-left: 35px; } .text-input { display: none; } .wrapper:hover .text-input { display: block; } 
 <div> <div class=wrapper> <div class=element> <input class=text-input type="text" name="search" /> </div> </div> </div> 

https://codepen.io/anon/pen/BOzJxL https://codepen.io/anon/pen/BOzJxL

I need the the textinput to appear next to the hotpink div elemenet (it needs to stay where it is when the input appears). 我需要将textinput出现在hotpink div elemenet (它需要保持在input出现时的位置)。 I need it to appear bit-by-bit - sort of being revealed pixel by piyxel. 我需要它一点一点地出现-一种被piyxel揭示的像素。 When leaving the div, I want it to be hidden again - same style as it came in. 离开div时,我希望它再次隐藏-与它的样式相同。

This will work for you. 这将为您工作。

 .wrapper { height: 40px; width: 75px; border-style: solid; border-width: 2px; border-radius: 40px; border-color: red; display: flex; align-items: center; padding-left:30px; -webkit-transition: width 0.4s ease-in-out; box-sizing:border-box; } .element { background-color: hotpink; width: 10px; height: 10px; } .wrapper:hover { width: 100%; } .text-input { max-width: 0; float: left; padding: 0px; border: 0px transparent; -webkit-transition:max-width 0.6s ease-in-out; transition:max-width 0.6s ease-in-out; } .wrapper:hover .text-input { max-width: 50%; padding: 2px; border: 1px solid #d4d4d4; } 
 <div class="wrapper"> <div class="element"></div> <input class="text-input" type="text" name="search" /> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM