列表动画

单一的使用<transition>标签来控制动画过渡

而使用v-for生成渲染出的则需要使用<transition-group>标签来控制

<transition-group appear tag="ul" >
            <li v-for="(item,i) in list" :key="item.id">{{item.id}}_______{{item.name}}<a href="javascript:;" @click="del(i)">移除</a></li>
</transition-group>

注意: 为v-for创建出来的元素设置动画,必须为每一个添加:key属性

此外还可以给<transition-group>添加appear属性:实现入场的动画过渡效果

使用<transition-group>时,会在审查元素中多渲染出<span>标签,为了遵循w3c,可以给予tag='ul',来让此渲染成ul标签

 

应为是列表(多个)的动画,所以在css中多出了个v-move 属性;

v-move 表示元素在改变定位的过程中应用(例如删除上一个,下面的也会再次触发动画过渡)

如果要使用v-move时,一定要在v-leave-active中加上 position:absolute属性,

也可以在<transition-group>标签中 添加 move-class="xxx"(多用于第三方库,或提前写好的css动画样式)

.v-move {
     transition: all 1.5s;
}
.v-leave-active {
     position: absolute;
}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,我可以为您提供一些基本的代码和思路来实现这个登录界面。 首先,我们需要一个 HTML 页面来定义登录界面的结构。 ``` <!DOCTYPE html> <html> <head> <title>Login Page</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="container"> <h2>Login</h2> <form action=""> <label for="username">Username:</label> <input type="text" id="username" name="username" required> <label for="password">Password:</label> <input type="password" id="password" name="password" required> <div class="dropdown"> <button class="dropbtn">Select Language</button> <div class="dropdown-content"> <a href="#">English</a> <a href="#">Chinese</a> <a href="#">Spanish</a> </div> </div> <button type="submit">Login</button> </form> <div class="collapse"> <button class="collapsible">Forgot Password?</button> <div class="content"> <p>Please enter your email address to reset your password:</p> <input type="email" id="email" name="email" required> <button>Reset Password</button> </div> </div> </div> <script src="script.js"></script> </body> </html> ``` 在这个页面中,我们定义了一个包含登录表单、下拉列表和折叠菜单的容器。表单包含了用户名、密码和登录按钮。下拉列表包含了一些语言选项,并且可以通过点击按钮展开和收起。折叠菜单包含了一个“忘记密码?”按钮和一个用于输入邮件地址的文本框。 接下来,我们需要使用 CSS 来定义样式,以便界面看起来更漂亮。 ``` .container { margin: 50px auto; width: 400px; padding: 20px; border: 1px solid #ccc; border-radius: 10px; box-shadow: 0px 0px 10px #ccc; } h2 { text-align: center; margin-bottom: 20px; } form { display: flex; flex-direction: column; } label { margin-top: 10px; } input[type="text"], input[type="password"], input[type="email"] { padding: 5px; border: 1px solid #ccc; border-radius: 5px; margin-bottom: 10px; } button[type="submit"], button { background-color: #4CAF50; color: white; padding: 10px; border: none; border-radius: 5px; cursor: pointer; margin-top: 10px; } button[type="submit"]:hover, button:hover { background-color: #3e8e41; } /* Dropdown Button */ .dropdown { position: relative; display: inline-block; } /* Dropdown Content (Hidden by Default) */ .dropdown-content { display: none; position: absolute; z-index: 1; } /* Links inside the dropdown */ .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } /* Change color of dropdown links on hover */ .dropdown-content a:hover { background-color: #f1f1f1; } /* Show the dropdown menu on hover */ .dropdown:hover .dropdown-content { display: block; } /* Collapsible */ .collapsible { background-color: #eee; color: #444; cursor: pointer; padding: 18px; width: 100%; border: none; text-align: left; outline: none; font-size: 15px; } .active, .collapsible:hover { background-color: #ccc; } /* Content */ .content { padding: 0 18px; display: none; overflow: hidden; background-color: #f1f1f1; } ``` 在这个 CSS 文件中,我们定义了容器、标题、表单、标签、输入框、按钮、下拉列表和折叠菜单的样式。我们还使用了一些 JavaScript 代码来实现下拉列表和折叠菜单的动画效果。 最后,我们需要使用 JavaScript 来实现下拉列表和折叠菜单的动画效果。 ``` var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } }); } ``` 在这个 JavaScript 文件中,我们使用了一个循环来遍历所有的折叠菜单,并为它们添加了一个点击事件。当用户点击按钮时,我们会切换按钮的样式,并根据当前显示状态来展开或折叠折叠菜单。 这就是一个简单的带下拉列表动画和折叠菜单的登录界面的实现。您可以根据您的需要进行自定义和调整。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值