启视差效果(相对父元素移动)
来源:互联网 发布:淘宝工商银行不能付款 编辑:程序博客网 时间:2024/06/06 07:14
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>地图</title>
<link href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.css" rel="stylesheet">
<style type="text/css">
html,body{font-family: "微软雅黑";font-size: 14px;}
body,h1,h2,h3,h4,h5,div,span,p,ul,ol,dl,dt,dd,a,input,img,select{margin: 0;padding: 0;list-style: none;border: 0;font-weight: normal;outline: none;}
.parallax{width: 700px;height: 300px;border: 1px solid red;/*background: url(http://www.swiper.com.cn/demo/img/Parallax.jpg) center center no-repeat;background-size: 100%;*/}
.swiper-container{color: white;width: 700px;height: 300px;position: relative;}
.parallax-bg {
position: absolute;
left: 0;
top: 0;
width: 130%;
height: 100%;
background: url(http://www.swiper.com.cn/demo/img/Parallax.jpg) center center no-repeat red;
-webkit-background-size: cover;
background-size: cover;
}
/*data-swiper-parallax="-23%"的23的算法是0.23*宽+700=总宽*/
</style>
</head>
<body>
<div class="parallax">
<div class="swiper-container">
<div class="parallax-bg" data-swiper-parallax="-23%" data-swiper-parallax-duration="500"></div>
<div class="swiper-wrapper">
<div class="swiper-slide">第一张</div>
<div class="swiper-slide">第二张</div>
<div class="swiper-slide">第三张</div>
</div>
<!-- 如果需要导航按钮 -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
</div>
</body>
<script src="http://guangzhou.auto.qq.com/js/jquery.min3.2.1.js"></script>
<script src="http://guangzhou.auto.qq.com/js/swiper.min3.4.2.js"></script>
<script type="text/javascript">
$(function(){
var mySwiper = new Swiper ('.swiper-container', {
// autoplay:2000,
parallax : true,
direction:'horizontal',
loop: false,
// 如果需要前进后退按钮
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
})
})
</script>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>地图</title>
<link href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.css" rel="stylesheet">
<style type="text/css">
html,body{font-family: "微软雅黑";font-size: 14px;}
body,h1,h2,h3,h4,h5,div,span,p,ul,ol,dl,dt,dd,a,input,img,select{margin: 0;padding: 0;list-style: none;border: 0;font-weight: normal;outline: none;}
.parallax{width: 700px;height: 300px;border: 1px solid red;/*background: url(http://www.swiper.com.cn/demo/img/Parallax.jpg) center center no-repeat;background-size: 100%;*/}
.swiper-container{color: white;width: 700px;height: 300px;position: relative;}
.parallax-bg {
position: absolute;
left: 0;
top: 0;
width: 130%;
height: 100%;
background: url(http://www.swiper.com.cn/demo/img/Parallax.jpg) center center no-repeat red;
-webkit-background-size: cover;
background-size: cover;
}
/*data-swiper-parallax="-23%"的23的算法是0.23*宽+700=总宽*/
</style>
</head>
<body>
<div class="parallax">
<div class="swiper-container">
<div class="parallax-bg" data-swiper-parallax="-23%" data-swiper-parallax-duration="500"></div>
<div class="swiper-wrapper">
<div class="swiper-slide">第一张</div>
<div class="swiper-slide">第二张</div>
<div class="swiper-slide">第三张</div>
</div>
<!-- 如果需要导航按钮 -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
</div>
</body>
<script src="http://guangzhou.auto.qq.com/js/jquery.min3.2.1.js"></script>
<script src="http://guangzhou.auto.qq.com/js/swiper.min3.4.2.js"></script>
<script type="text/javascript">
$(function(){
var mySwiper = new Swiper ('.swiper-container', {
// autoplay:2000,
parallax : true,
direction:'horizontal',
loop: false,
// 如果需要前进后退按钮
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
})
})
</script>
</html>
原来是这样
阅读全文
0 0
- 启视差效果(相对父元素移动)
- 背景移动视差效果
- 让元素相对移动
- 视差效果
- parallax(视差)效果源码分析
- UIView添加背景视差效果(MotionEffect)
- iOS 开眼效果中的视差效果(UITableViewController)
- Parallax视差动画效果
- MJParallaxCollectionView 视差滑动效果
- ListView头部视差效果
- win10 uwp 视差效果
- 视差效果实现
- tableview 视差效果
- 视差滚动效果
- Andengine的自动视差背景AutoParallaxBackground(背景移动)
- 相对父级元素定位
- 头部视觉视差(仿QQ控件下拉效果)
- 通过overScrollBy实现下拉视差特效(阻尼效果)
- PAT1007. Maximum Subsequence Sum (25)
- HMM经典介绍论文【Rabiner 1989】翻译(十)——连续观测密度
- winform 鼠标指针移过组件选中行勾选移开未选中去除勾选
- idea 配置 springMvc dome
- CRT的使用,发布项目
- 启视差效果(相对父元素移动)
- Java 中Class文件详解
- 小程序之显示 隐藏功能(二)
- zoj 3502 Contest (状态压缩dp)
- opencv-图像拼接与融合
- Kotlin函数式编程(二) 高阶函数
- pip list warning
- GDB调试入门
- tomcat启动时报错OutOfMemoryError: Java heap space