css 的通用样式 设置 和倒计时功能 移动轮播图的手势滑动的功能
body{
line-height:1.4;
color:#333;
font-family:arial;
font-size: 12px;
background:white;
}
input,textarea,select{
font-size:12px;
font-size:100%;
font-family:arial;
font-family:inherit;
}
body,h1,h2,h3,h4,h5,h6,p,ul,ol,form{
margin:0;
}
h4,h5,h6{
font-size:1em;
}
ul,ol{
padding-left:0;
list-style-type:none;
}
/*image with no-border*/
a img{border:0;}
img{border:0;}
*,::before,::after{
margin: ;
padding: ;
/*
盒模型,改变盒子的计算大小的方式。
*/
box-sizing: border-box;
/*移动浏览器基本上的内核都是webkit*/
-webkit-box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}
body{
color: #;
/*
字体样式,默认是微软雅黑, 默认当前设备自带的字体。
*/
font-family: "Microsoft YaHei", sans-serif; font-size: 14px;
} a{
text-decoration: none;
}
a:hover{
text-decoration: none;
color: #;
}
ol,ul{
list-style: none;
}
/*
表单里面的input 框默认样式很丑
*/
input{
border: none;
outline: none;
appearance:none;
/*
清楚input 原有的样式。
*/
-webkit-appearance: none;
}
/*
获取页面上面所有的元素,class 的值以icon_ 开头。
*/
[class^=icon_]{
background: url("../images/sprites.png");
background-size: 200px 200px;
} /*提炼浮动*/
.f_left{
float: left;
}
.f_right{
float: right;
}
body{
background: #f5f5f5;
}
/*顶部通栏*/
.jd_layout{
max-width: 640px;
min-width: 320px;
margin: 0 auto;
height: 1000px;
} .jd_header{
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 40px;
z-index: 1000;
} .jd_header>.jd_header_box{
max-width: 640px;
min-width: 320px;
height: 40px;
background:rgba(201,21,35,0) ;
margin: 0 auto;
position: relative;
}
.jd_header>.jd_header_box .icon_logo{
background-position: 0 -103px;
position: absolute;
left: 3px;
top: 5px;
width: 60px;
height: 30px;
}
.jd_header>.jd_header_box .login{
position: absolute;
right: 3px;
top: 0px;
height: 40px;
line-height: 40px;
font-size: 16px;
color: #fff;
}
.jd_header>.jd_header_box form{
padding-left: 65px;
padding-right: 45px;
}
.jd_header>.jd_header_box form input{
width: 100%;
height: 30px;
margin-top: 5px;
border-radius: 15px;
padding-left: 30px;
}
.jd_header>.jd_header_box form .icon_search{
position: absolute;
left: 73px;
width: 20px;
height: 20px;
top: 10px;
background-position: -60px -109px;
} /*轮播图*/
.jd_banner{
/*640px*/
width: 100%;
overflow: hidden;
position: relative;
}
.jd_banner ul:nth-child(1){
width: 1000%;
transform: translateX(-10%);
}
.jd_banner ul:nth-child(1)>li{
width: 10%;
float: left;
}
.jd_banner ul:nth-child(1)>li>a{
display: block;
}
.jd_banner ul:nth-child(1)>li>a>img{
width: 100%;
vertical-align: bottom;
}
.jd_banner ul:nth-child(2){
position: absolute;
left: 50%;
width: 118px;
bottom: 6px;
margin-left: -59px;
height: 6px;
}
.jd_banner ul:nth-child(2) li{
border: 1px solid #fff;
height: 6px;
width: 6px;
border-radius: 50%;
margin-left: 10px;
float: left;
}
.jd_banner ul:nth-child(2) li.now{
margin-left: 0;
background: #fff;
} /*nav*/
.jd_nav{ }
.jd_nav>ul{
width: 100%;
background: #fff;
border-bottom: 1px solid #ccc;
overflow: hidden;
}
.jd_nav>ul>li{
width: 25%;
float: left;
text-align: center;
margin: 10px 0;
}
.jd_nav>ul>li>a{ }
.jd_nav>ul>li>a>img{
width: 40px;
height: 40px;
}
.jd_nav>ul>li p{
font-size: 12px;
} /*商品区域*/
.jd_product>.jd_product_box{
min-height: 300px;
} .jd_product>.jd_product_box>.product_tit{
height: 30px;
border-bottom: 1px solid #ccc;
} .jd_product>.jd_product_box>.product_tit>h3::before{
content: '';
width: 5px;
height: 20px;
display: block;
background: rgba(201,21,35,0.85);
position: absolute;
left: 3px;
top: 5px;
} .jd_product>.jd_product_box>.product_tit>h3{
font-weight: normal;
position: relative;
padding-left: 15px;
height: 30px;
line-height: 30px; }
/*秒杀区域*/
.jd_sk{ }
.jd_sk .seconds_kill{
background: url("../images/seckill-icon.png");
background-size: 16px 20px;
margin-left: 5px;
margin-top: 5px;
width: 16px;
height: 20px;
float: left;
}
.jd_sk .seconds_text{
height: 30px;
line-height: 30px;
float: left;
margin-left: 10px; }
.jd_sk .sk_time{
float: left;
margin-left: 10px;
height: 30px;
line-height: 30px;
}
.jd_sk .sk_time>span{
background: #000;
color: #fff;
} .jd_sk .sk_time>span:nth-child(3n){
background: #fff;
color: #000;
}
.jd_sk .right_more {
height: 30px;
line-height: 30px;
margin-right: 10px;
}
轮播图的功能实现 移动端的手势滑动;
window.onload=function(){
/*滚动条滚动,*/
search(); //轮播图
banner(); //倒计时
downTime();
}
/*搜索框滚动*/
function search(){
/*
* 1: 我要获取到轮播图的高度
* 2:我要获取到顶部的header
* */
var header_box=document.querySelector(".jd_header_box");
var banner=document.querySelector(".jd_banner");
var h=banner.offsetHeight;
//监控滚动条滚动
window.onscroll=function(){
var opacity=0;
//滚动条的距离
var top=document.body.scrollTop;
if(top<h){
opacity=top/h*0.85;
}else{
opacity=0.85;
}
//我在滚动的时候我要去改透明度
header_box.style.background="rgba(201,21,35,"+opacity+")";
}
} function banner(){
/*
* 1: 获取页面上面dom 元素
* 2:动态的去滚动 定时器, translateX() transition
* 3:图片滚动,盒子对应的点随着变化
* 4:图片跟着我的手指触摸的位置的变化而变化
* 5:我的手指滑动,当滑动超过一定的距离
* 我就跳到下一张
* 没有超过一定的距离,
* 吸附回去
* */
//获取到的是轮播的外面的带盒子
var banner=document.querySelector(".jd_banner");
//
var imageBox=banner.querySelector("ul:first-child"); var pointsBox=banner.querySelector("ul:last-child");
//获取到屏幕的宽度
var w=banner.offsetWidth;
//获取到所有的点
var pointlis=pointsBox.querySelectorAll("li"); //我用来记录这个图片盒子的索引
var index=1; var addTransition=function(){
imageBox.style.transition="all 0.2s";
imageBox.style.webkitTransition="all 0.2s";
}; var removeTransition=function(){
imageBox.style.transition="none";
imageBox.style.webkitTransition="none";
} //位置移动。
var addTranslate=function(w){
imageBox.style.transform="translateX("+w+"px)";
imageBox.style.webkitTransform="translateX("+w+"px)";
} var timer=setInterval(function(){
index++;
//添加过度
addTransition();
//必须动态的去改谁
addTranslate(-index*w);
},1000);
/* //我需要把动态的滚动做出来。我必须就要添加定时 *我可以transitionEnd*/
itcast.transitoinEnd(imageBox,function(){
if(index<=0){
index=8;
removeTransition();
addTranslate(-index * w);
}
else if(index>=9){
index=1;
removeTransition();
addTranslate(-index * w);
}
//修改盒子点的样式。
setPoint(index);
});
/* 修改 盒子的点的样式*/
var setPoint=function(index){
for(var i=0;i<pointlis.length;i++){
//把一个class 等于移除掉
pointlis[i].classList.remove("now");
}
//给每个轮播对应的点添加样式。
console.log(index);
pointlis[index-1].classList.add("now");
};
/*
* 1:我的触屏移动,imageBox 跟着移动
* 2:假设我触屏结束,判断的触屏滑动的距离,如果说超过了一定的距离,我就跳到下一张,
* 否则吸附回去。
*
* */ //这个是用来记录触屏开始的点的位置。
var startX=0; //移动的触摸点的位置x
var moveX=0; //移动的距离
var distinceX=0; //判断我的触摸是否移动
var isMove=false; //触屏开始
imageBox.addEventListener("touchstart",function(event){
console.log("start");
//触摸开始,循环结束
clearInterval(timer);
//记录触摸的起点位置。
/*
* event 里面记录所有的触摸点,肯定也会记录触摸点的位置,
* 怎么去获取水平的位置。
* */
startX=event.touches[0].clientX;
console.log(event.touches[0].clientX); });
//移动
imageBox.addEventListener("touchmove",function(event){
console.log("move");
//记录触摸点移动的位置。
isMove=true;
//我的轮播图肯定要跟着我的触摸点进行移动
moveX=event.touches[0].clientX;
//console.log(moveX);
//我需要startX 与moveX 位置计算出来。
distinceX=moveX-startX; //这里的值可能是正数,也可能是负数
//当前imageBox 要移动的距离
var current=(-index*w)+distinceX;
//我要移除这个过度,否则,会有卡顿的效果。
removeTransition();
addTranslate(current); })
//触屏离开
imageBox.addEventListener("touchend",function(){
console.log("end")
/*
* 判断用户触摸移动的距离。如果没有超过一定的位置,我们就要吸附回去
* 如果超过了一定的位置,我还需要判断是滑动下一张,还是上一张。
* */
if(isMove && Math.abs(distinceX)>w/3){
//图片移动
//我要判断是向左还是向右滑动
if(distinceX>0){
index--;
}else{
index++;
} //吸附回去
addTransition();
addTranslate(-index*w);
}else{
//吸附回去
addTransition();
addTranslate(-index*w);
} //触摸结束,循环继续
timer=setInterval(function(){
index++;
//添加过度
addTransition();
//必须动态的去改谁
addTranslate(-index*w);
},1000);
})
}
// 15:59:59 倒计时的功能实现;
function downTime(){
//这个时间是从后台获取到的,发送一个请求,服务器返回数据,返回的是一个时间。
var timeinfo=60*60*15; var spans=document.querySelectorAll(".sk_time>span"); setInterval(function(){ if(timeinfo<=0){
//发送一个请求给服务器。返回一些数据更换掉秒杀的商品。
return;
} timeinfo--; //把这个时间格式化之后放在 var h=Math.floor(timeinfo/3600); //分钟
var m=Math.floor(timeinfo%3600/60); //秒
var s=timeinfo%60; spans[0].innerHTML=Math.floor(h/10);
spans[1].innerHTML=h%10; //分钟
spans[3].innerHTML=Math.floor(m/10);
spans[4].innerHTML=m%10; //秒钟
//分钟
spans[6].innerHTML=Math.floor(s/10);
spans[7].innerHTML=s%10;
},1000); }
css 的通用样式 设置 和倒计时功能 移动轮播图的手势滑动的功能的更多相关文章
- 再谈iOS 7的手势滑动返回功能
本文转载至 http://blog.csdn.net/jasonblog/article/details/28282147 之前随手写过一篇<使用UIScreenEdgePanGestureR ...
- 禁用ios7 手势滑动返回功能
禁用ios7 手势滑动返回功能 版权声明:本文为博主原创文章,未经博主允许不得转载. 在有的时候,我们不需要手势返回功能,那么可以在页面中添加以下代码: - (void)viewDidAppear:( ...
- iOS之手势滑动返回功能-b
iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的 ...
- iOS之手势滑动返回功能
iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的 ...
- 【jQuery】全功能轮播图的实现(本文结尾也有javascript版)
轮播图 图片自动切换(定时器): 鼠标悬停在图片上图片不切换(清除定时器) 鼠标悬停在按钮上时显示对应的图片(鼠标悬停事件) 鼠标悬停在图片上是现实左右箭头 点击左键切换到上一张图片,但图片为第一张时 ...
- 一百二十八:CMS系统之轮播图的编辑和删除功能
编辑 form,继承添加的form 视图 @bp.route('/ubanners/', methods=['POST'])@login_required@permission_required(CM ...
- CSS 文本字体颜色设置方法(CSS color)
CSS 文本字体颜色设置方法(CSS color) 一.认识CSS 颜色(CSS color) 这里要介绍的是网页设置颜色包含有哪些:网页颜色规定规范. 1.常用颜色地方包含:字体颜色.超链接颜色.网 ...
- jquery里面的attr和css来设置轮播图竟然效果不一致
/*封装$*/ // window.$=HTMLElement.prototype.$=function(selector){ // var elems=(this==window?document: ...
- 自定义listView添加滑动删除功能
今天研究了一下android里面的手势,结合昨天学习的自定义View,做了一个自定义的listview,继承自listView,添加了条目的滑动手势操作,滑动后出现一个删除按钮,点击删除按钮,触发一个 ...
随机推荐
- NPD南京炮苑电子技术研究所----NPD治疗仪
NPD南京炮苑电子技术研究所有限公司: http://www.npd365.com/ 研发药物离子导入和中医定向透药技术. 南京炮苑玉古康2号NPD系列专用中医定向透药治疗仪腰颈椎疼痛贴 N ...
- 以下内容为Stackoverflow上整理以作纪录
PRO 用IMG标签 Use IMG plus alt attribute if the image is part of the content such as a logo or diagram ...
- Openshift初步学习问题集
1.设置资源限额 详细参考 https://docs.openshift.com/enterprise/3.2/admin_guide/quota.html#sample-resource-quota ...
- OpenCV支持向量机SVM对线性不可分数据的处理
支持向量机对线性不可分数据的处理 目标 本文档尝试解答如下问题: 在训练数据线性不可分时,如何定义此情形下支持向量机的最优化问题. 如何设置 CvSVMParams 中的参数来解决此类问题. 动机 为 ...
- Windows10的周年更新中无法关闭Cortana?这里有方法
备受期待的Windows 10的周年更新中将会带来诸多新特性,包括更实用的开始菜单.Windows Ink.强化的Windows Defender,甚至还有一个无法关闭的语音助手Cortana. 目前 ...
- [TypeScript] Work with DOM Elements in TypeScript using Type Assertions
The DOM can be a bit tricky when it comes to typing. You never really know exactly what you're going ...
- 程序的入口及AppDelegate窗体显示原理
AppDelegate.m - (void)dealloc { [_window release]; [super dealloc]; } - (BOOL)application:(UIApplica ...
- 如何修改JComboBox的宽度
代码: String[] arr={"http://itts.ihe.ufo.com/rtts/ws.jsp","http://ittsstg.ihe.ufo.com/r ...
- Android NDK 交叉编译C++代码生成.so共享库详细步骤
Android NDK 交叉编译C++代码生成.so共享库详细步骤 Android NDK 调用c++ stl 模板库(修改android.mk文件) 1 在需要调用模板库的文件前包含头文件: ...
- Django 学习记录
这是我自己理解并自己画的,django 请求示意图,表示了它的组织方式. project manage.py: 主要工具文件 settings.py: 配置文件 urls.py: url 定义及其指向 ...