点击按钮实现页面滑动展示效果

点击“点我,去看文章2”,会出现文章2页面模板向左滑动效果
在这里插入图片描述

点击“点我,去看文章1”,会出现文章1页面模板向右滑动效果
在这里插入图片描述

<style type="text/css">
	#wrapper{
			width: 100%;
			overflow: hidden;
		}
		.articleCon{
			width: 200%;
			display: flex;
		}
		.article1,
		.article2{
			width: 100%;
			height: 400px;
		}
		.article1{
			background: blue;
		}
		.article2{
			background: cyan;
		}
</style>
<div id="wrapper">
	<div class="articleCon">
		<div class="article1">
			<button type="button" id="viewArticle2">展示文章2</button>
			<div>
				hello,我是文章1
			</div>
		</div>
		<div class="article2">
			<button type="button" id="viewArticle1">展示文章1</button>
			<div>
				hello,我是文章2
			</div>
		</div>
	</div>
</div>
<script src="./assets/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$("#viewArticle2").click(function(){
		$(".articleCon").css({
			"margin-left":"-100%",
			"transition":"all 2s"
		})
	})
	$("#viewArticle1").click(function(){
		$(".articleCon").css({
			"margin-left":"0%",
			"transition":"all 2s"
		})
	})
</script>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值