点击搜索框动画变长,搜索框有内容不变,无内容失去焦点,变回原来模样。<div :class="type == true ? 's_r_z' : 's_r'" @click="onChange"><div class="input_s"><input @blur="handleBlur" v-model="input" required placeholder="请输入关键词搜索" /></div><img src="../../../../assets/images/v_15.png" /></div>mounted() {// 监听全局点击事件window.addEventListener('click', this.handleClickOutside);},beforeDestroy() {// 组件销毁前移除监听事件window.removeEventListener('click', this.handleClickOutside);},methods: {// 如果点击事件的目标不是打开的div也不是其子元素,则关闭divhandleClickOutside(event) {if (!this.$el.contains(event.target) && this.type && this.input == '') {this.type = false;}},onChange() {this.type = true},
}.s_r {display: flex;width: 62px;height: 30px;background: #E3F1FF;border-radius: 20px;cursor: pointer;margin: 0px 0px 0px 30px;margin-top: -7px;transition: all 1s ease-in-out;-webkit-transition: width 1s;img {width: 20px;height: 20px;position: relative;left: 20px;top: 5px;}input {display: none;}}.s_r_z {display: flex;justify-content: center;align-items: center;width: 240px;height: 30px;background: #E3F1FF;border-radius: 20px;border: 1px solid #258DEC;animation: kx 0.5s;margin: 0px 0px 0px 30px;margin-top: -8px;img {width: 20px;height: 20px;}input {outline-style: none;border: none;background-color: #E3F1FF;animation: zk 1s;}}@keyframes kx {0% {width: 0px}100% {width: 240px;}}@keyframes zk {0% {width: 0px}100% {width: 200px;}}
CSS - 搜索框小动效
2025/2/24 0:46:01
来源:https://blog.csdn.net/qq_40894259/article/details/141859411
浏览:
次
关键词:CSS - 搜索框小动效
版权声明:
本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。
我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com
热文排行
- 华为 海思22AP10(SS524)H.265 编解码处理器用户指南
- 数据库物理结构设计
- 如何在 Mac 上清空硬盘后恢复丢失的数据?
- npm install puppeteer 报错 npm ERR! PUPPETEER_DOWNLOAD_HOST is deprecated解决办法
- 基于重要抽样的主动学习不平衡分类方法ALIS
- 《缺失MRI模态下的脑肿瘤分割的潜在相关表示学习》| 文献速递-深度学习肿瘤自动分割
- 大模型分离架构学习记录
- (2)Django生产环境数据库的切换以及环境配置python-dotenv方案
- 【微信小程序】自定义组件 - 组件的生命周期
- vue项目——页面绑定回车Enter事件,进入页面路由和离开页面路由解绑事件——js技能提升