帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» CSS3案例之忍者滑动
CSS3案例之忍者滑动
浏览:1099次
-
评论:1次
-
发布时间:2017-12-25
Html
Css
Js
body { background-image:url(img/bg.png); background-size:cover; } .container { width:600px; height:400px; border:20px solid #fff; margin:0 auto; position:relative; } /* 对图的部分进行布局 **/ .tu { width:600px; height:400px; position:absolute; left:0; top:0; /*设置为弹性盒子来进行四等份*/ display:flex; } .tu>div { width:150px; height:400px; /*每个div占1份,分为四等份*/ flex:1; position:relative; /*点击滑动超出div则隐藏*/ overflow:hidden; } .tu>div>span { width:150px; height:400px; display:block; position:absolute; left:-150px; top:0; } .container >input { display:none; } .container > label { position:relative; z-index:9999; width:150px; height:40px; display:block; float:left; cursor:pointer; top:300px; } /*小球制作*/ .container>label:before { content:"1"; display:block; width:35px; height:35px; background-color:rgba(130,195,213,.9); box-shadow:0px 0px 0px 4px rgba(255,255,255,.3); border-radius:50%; text-align:center; line-height:35px; position:absolute; left:60px; color:white; } /*修改小球里的文字*/ .container>label:nth-child(5):before { content:"1"; } .container>label:nth-child(6):before { content:"2"; } .container>label:nth-child(7):before { content:"3"; } .container>label:nth-child(8):before { content:"4"; } .container> .xuan-1:checked ~ label:nth-child(5):before,.container> .xuan-2:checked ~ label:nth-child(6):before,.container> .xuan-3:checked ~ label:nth-child(7):before,.container> .xuan-4:checked ~ label:nth-child(8):before { color:rgba(130,195,213,.9); background-color:white; } /*放图片*/ .tu>div>span:nth-child(1) { background-image:url(http://www.sucainiu.com/themes/images/demo/500x300-1.png); } .tu>div>span:nth-child(2) { background-image:url(http://www.sucainiu.com/themes/images/demo/500x300-2.png); } .tu>div>span:nth-child(3) { background-image:url(http://www.sucainiu.com/themes/images/demo/500x300-3.png); } .tu>div>span:nth-child(4) { background-image:url(http://www.sucainiu.com/themes/images/demo/500x300-4.png); } /*div下的所有span进行向左偏移*/ .tu>div:nth-child(1)>span { background-position:0px 0px; } .tu>div:nth-child(2)>span { background-position:-150px 0px; } .tu>div:nth-child(3)>span { background-position:-300px 0px; } .tu>div:nth-child(4)>span { background-position:-450px 0px; } /*点击切换图片*/ .container>.xuan-1:checked~ .tu>div>span:nth-child(1),.container>.xuan-2:checked~ .tu>div>span:nth-child(2),.container>.xuan-3:checked~ .tu>div>span:nth-child(3),.container>.xuan-4:checked~ .tu>div>span:nth-child(4) { z-index:100; transition:left 0.5s ease-in-out; animation:none; left:0px; } /*所有背景进行移动*/ input:checked~ .tu>div span { animation:play 0.6s ease-in-out 0s 1; } @keyframes play { 0% { left:0px; } 100% { left:150px; } }/*边框*/ .container>label:after { width:1px; height:400px; background:-webkit-linear-gradient(top,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); content:""; display:block; position:absolute; right:0; bottom:-60px; }
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>CSS3案例之忍者滑动-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:CSS3+弹性盒子
简单的CSS3+弹性模型制作图片滑动案例
jQuery下拉选择框获取一个或多个值
自动格式化大数字
讨论这个常用代码(1)
回答他人问题或分享心得会奖励牛币
Lv10 CTO
华***n
2017年12月28日
学习了 感谢分享~
回复
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
1099
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值