APP 半自适应 WEB页面

摘要:
特别快速、响应迅速、适应性强。我有空时写了一篇新文章。

特别赶,响应式纯自适应的,有空写了新的发。 (在手机上看,页面上看一定乱)

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="UTF-8">
<meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta http-equiv="Cache-Control" content="no-transform ">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">


<script src="http://t.zoukankan.com/jquery-1.9.1.js"></script>
<title>无缝连接滚动</title>
<style>
html,body,ul,li{
margin:0; padding:0;
}
a{
text-decoration:none;
}
#s_height ul li{
z-index:9;
list-style-type:none;
float:left;
overflow:hidden;
display:black;
}

#d_Layout ul li{
list-style-type:none;
float:left;
text-align:center;
}
#d_cilck{
100%;
}
#s_us{
right:20px; position:absolute; margin-top:-25px; z-index:999;
}
#s_us ul li{
list-style-type:none;
float:left;
padding-left:15px;
}
#s_us ul li{
margin-left:15px;
border-radius:25px; border:2px solid #ffffff;padding:5px;
}



</style>

</head>

<script>

$(function(){
var t_name={
t_lb:$("#s_Shell ul li"),
s_h:$("#s_height"),
Carousel_img:$("#s_heights ul li"),
Carousel_imgs:$("#s_heights ul li img"),
s_Sc:$("#Seamless_carousel"),
s_ul:$("#s_us ul li"),
s_slM:$(".slider-mains")
};

//全局变量,触摸开始位置
var startX=0,startY=0,x=0,i=2,c=3,sWidths= t_name.s_h.width();
//touchstart事件 在触摸开始时触发事件
function touchSatrtFunc(evt){
try
{
//evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等
var touch = evt.touches[0]; //获取第一个触点
x = Number(touch.pageX); //页面触点X坐标
//记录触点初始位置
startX = x;
}
catch (e) {
console.log('touchSatrtFunc:' + e.message);
}
}

//touchmove事件,这个事件无法获取坐标
function touchMoveFunc(evt) {
try
{
//evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等
var touch = evt.touches[0]; //获取第一个触点
x = Number(touch.pageX); //页面触点X坐标
var y = Number(touch.pageY); //页面触点Y坐标
}
catch (e) {
console.log('touchSatrtFunc:' + e.message);
}
}

//touchend事件 在触摸结束时触发事件
function touchEndFunc(evt) {
try {
//evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等
t_Carousel.z_lb(t_name.t_lb,x<startX);
t_Carousel.z_lz(t_name.t_lb,x>startX);
window.clearInterval(timeID);
timeID=setInterval(function(){t_Carousel.z_lb(t_name.t_lb,true)},4000);
}
catch (e) {
console.log('touchEndFunc:' + e.message);
}
}

//绑定事件
function bindEvent() {
document.addEventListener('touchstart', touchSatrtFunc, false);
document.addEventListener('touchmove', touchMoveFunc, false);
document.addEventListener('touchend', touchEndFunc, false);
}

//判断是否支持触摸事件
function isTouchDevice(){
console.log(navigator.appVersion);
try {
document.createEvent("TouchEvent");
bindEvent(); //绑定事件

}
catch (e) {
console.log("不支持TouchEvent事件!" + e.message);
}
}

window.onload = isTouchDevice;


var t_Carousel={
z_lb:function(t,z){
if(z){

if(i>=4){

t_name.s_slM.stop(true).animate({"margin-left":"-"+(i*sWidths)+"px"},1000);
i=1;

t_name.s_slM.animate({"margin-left":"-"+(i*sWidths)+"px"},0);
t_name.s_ul.eq(i-1).css({"transform":"scale(1.1)","background-color":"#ffffff"}).siblings().css({"transform":"scale(1)","background-color":"transparent"});
}else{
t_name.s_slM.animate({"margin-left":"-"+(i*sWidths)+"px"},1000);
t_name.s_ul.eq(i-1).css({"transform":"scale(1.1)","background-color":"#ffffff"}).siblings().css({"transform":"scale(1)","background-color":"transparent"});

}
if(true){

i==1?c=0:i==2?c=1:c=2;

}
if(i<=4){
i++
}else{
i=5;
}
}

},
z_lz:function(t,z){
if(z){
$("#sts").css("display","block");
t_name.s_ul.eq(c-1).css({"transform":"scale(1.1)","background-color":"#ffffff"}).siblings().css({"transform":"scale(1)","background-color":"transparent"});
if(c>=3){
var t=c-3;
t_name.s_slM.stop(true).animate({"margin-left":"-"+(t*sWidths)+"px"},1000);

t_name.s_slM.animate({"margin-left":"-"+(c*sWidths)+"px"},0);
}else{
t_name.s_slM.animate({"margin-left":"-"+(c*sWidths)+"px"},1000);


}

c--;
if(true){
if(c<=-1){
i=1;
}else{
c==2?i=4:c==1?i=3:i=2;}
}
if(c>1){

c=2;

}
if(c<0)
{
c=3;
}
}


}
}

function Automatic_at(){
var sWidth= t_name.s_h.width();
var sWidthTo=Number(sWidth*(5/8));

t_name.s_Sc.attr("style",""+sWidth+"px;overflow:hidden;");
t_name.Carousel_img.attr("style","height:"+sWidthTo+"px;"+sWidth+"px;min-height: 80px;");
t_name.Carousel_imgs.attr("style","height:"+sWidthTo+"px;"+sWidth+"px;min-height: 80px;");
t_name.s_h.attr("style","height:"+sWidthTo+"px;100%;min-height: 80px;");
$("#sts").attr("style",""+sWidth+"px;overflow:hidden; display:none;");
$(".slider-mains").attr("style","margin-left:-500px;");
}

$(window).resize(function(){
Automatic_at();
});

Automatic_at();
timeID=setInterval(function(){t_Carousel.z_lb(t_name.t_lb,true)},4000);
});



</script>

<body>
<div >
<div class="s_width">
<div >
<div >
<ul >
<li ><img src="http://t.zoukankan.com/ img/item2.jpg"/></li>
<li ><img src="http://t.zoukankan.com/ img/ss.png"/></li>
<li ><img src="http://t.zoukankan.com/ img/item1.jpg"/></li>
<li ><img src="http://t.zoukankan.com/ img/item2.jpg"/></li>
<li ><img src="http://t.zoukankan.com/ img/ss.png"/></li>
</ul>
</div>
</div>
</div>
<div >
<ul>
<li style="background-color:#ffffff; transform:scale(1.1);"><div ></div> </li>
<li><div ></div> </li>
<li><div ></div> </li>
</ul>
</div>


</body>
</html>

免责声明:文章转载自《APP 半自适应 WEB页面》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇golang中使用Redis小程序自定义轮播图下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

仿苹果电脑任务栏菜单&amp;amp;&amp;amp;拼图小游戏&amp;amp;&amp;amp;模拟表单控件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> &...

CSS尺寸与补白

尺寸与补白 width 语法: width:长度值 | 百分比 | auto 默认值:auto 适用于:除非置换内联元素,table-row, table-row-group之外的所有元素 继承性:无 动画性:当值为 长度值 | 百分比 时 计算值:指定的值 媒 体:视觉 取值: auto: 无特定宽度值,取决于其它属性值 长度值: 用长度值来定义宽度...

flex自适应高度内容高度超出容器高度自动出现滚动条的问题

在容器中设置 flex-grow:2; overflow-y:auto;overflow-x:hidden;容器高度自适应。 内容高度不固定,无法出现滚动条,然后在容器中添加height:0,出现滚动条,个人猜想为设置height:0后,将默认的盒子模型高度设置为空,让flex设置的高度生效; //TODO 实验,查资料...

CSS之显示天气

 这个可以有,自从有了这个,以后查询天气就方便多了,哈哈。 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <titl...

使用jQuery和Bootstrap实现多层、自适应模态窗口

本篇实践一个多层模态窗口,而且是自适应的。   点击页面上的一个按钮,弹出第一层自适应模态窗口。   在第一层模态窗口内包含一个按钮,点击该按钮弹出第二层模态窗口,弹出的第二层模态窗口会挡住第一层模态窗口,即第二层模态窗口打开的时候,无法关闭第一层模态窗口。     具体页面实现部分如下: <head> <meta http-equ...

Bootstrap自适应各种设备

<!DOCTYPE html><html><head><title>Bootstrap 实例 - 手机、平板电脑、台式电脑</title><meta charset="utf-8"><meta name="viewport" content="width=device-width...