直接上代码: 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			#container{
				position: relative;
			}
			#btn{
				width: 100%;
				height: 50px;
			}
			.bottom{
				position: fixed;
				width: 100%;
				padding: 20px;
				background-color: skyblue;
				bottom: 0px;
				
				transform: translateY(100%);
				
				transition:all 2s;
				-moz-transition:all 2s; /* Firefox 4 */
				-webkit-transition:all 2s; /* Safari and Chrome */
				-o-transition:all 2s; /* Opera */
			}
			
			
		</style>
	</head>
	<body>
		
		<div id="container">
			
			<button id="btn" @click="btn">button</button>
			
			<div  v-bind:class="['bottom']"  v-bind:style="{transform: 'translateY('+num+'%)'}">
				<p>123</p>
				<p>123</p>
				<p>123</p>
				<p>123</p>
				<p>123</p>
			</div>
		</div>
		
		
		
		<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
		<script>
			var vm = new Vue({
				el: '#container',
				data: {
					flag: true,
					cl: '',
					num: '100'
				},
				methods: {
					btn: function(){
						if(this.flag){
							this.num = 0
						}else{
							this.num = '100'
						}
						this.flag = !this.flag;
					}
				}
			});
		</script>
	</body>
</html>

 

Logo

前往低代码交流专区

更多推荐