博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
angular轮播图
阅读量:4634 次
发布时间:2019-06-09

本文共 2625 字,大约阅读时间需要 8 分钟。

还是直接上代码比较好

<!doctype html>

<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<link rel="stylesheet" type="text/css" href="css/animate.min.css"/>
<style type="text/css">
.tabs{position:relative;width: 100%;height: 100%; overflow: hidden;}
.tabs ol,.tabs ol li{list-style: none; }
.tabs ol{position: absolute;left: 50%;bottom: 50px;width: 160px;height: 15px;
margin-left:-80px;z-index: 1010;}
.tabs ol li{
float: left;width: 15px;height: 15px;margin-left: 10px;
border-radius: 50%; background: #ED346C;
line-height: 15px;text-align: center;font-size: 15px;background: #00b274;
}
.tab-pane-wrap{width: 100%;height: 1920px;position: relative;}
.tabs .tab-pane{
position:absolute;left:0;top:480px;width: 100%;height: 480px;
float: left;text-align: center;font-size: 50px;line-height: 250px;
}
.color0{background:#0000FF;}
.color1{background: #0B4C6E;}
.color2{background: #2079BE;}
.color3{background: #2B542C;}
ol li.on{background:red ;}
.tabs .tab-pane.on{left: 0;top:0;}
section{
width: 600px;height: 480px;margin: 0 auto;
}
</style>
<script src="js/angular.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var app=angular.module('myapp',[]);
app.directive('tabs',function($interval){
return{
restrict:'E',//指定以某种格式来调用指令
//元素(E),属性(A),类(C),注释(M)
replace:true,//将自定义标签从生成的dom中完全移除
templateUrl:'index-link.html',
link:function(scope, element, attr){
scope.arr=['0','1','2','3'];
scope.cls=[
{cl1:'tab-pane',cl2:'color0',ani:'animated'},
{cl1:'tab-pane',cl2:'color1',ani:'animated'},
{cl1:'tab-pane',cl2:'color2',ani:'animated'},
{cl1:'tab-pane',cl2:'color3',ani:'animated'}
];
console.log($interval)
scope.now=0;
scope.old=999;
scope.click=function(index1){
scope.old=scope.now;
scope.now=index1;
};
var interval=$interval(function(){
scope.now++;
if(scope.now>3){
scope.now=0;
}
},2000);
scope.mouseenter=function(){
$interval.cancel(interval);
};
scope.mouseleave=function(){
interval=$interval(function(){
scope.now++;
if(scope.now>3){
scope.now=0;
}
},2000);
};
}
}
});

</script>

</head>
<body ng-app="myapp">
<tabs></tabs>
<script type="text/ng-template" id="index-link.html">
<section id="carouse" ng-mouseenter="mouseenter();" ng-mouseleave="mouseleave()">
<div class="tabs">
<ol>
<li ng-repeat="ind in arr" ng-click="click($index)" ng-class="{on:$index==now}">{
{ind}}</li>
</ol>
<div class="tab-pane-wrap">
<div ng-repeat="cl in cls" class="{
{cl.cl1}} {
{cl.cl2}} {
{cl.ani}}" ng-class="{on:$index==now,slideOutLeft:$index==old,lightSpeedIn:$index==now}"></div>
</div>
</div>
</section>
</script>
</body>
</html>

转载于:https://www.cnblogs.com/reaf/p/6618287.html

你可能感兴趣的文章
chkconfig
查看>>
day44前端开发1之html基础
查看>>
小甲鱼-004改进小游戏
查看>>
琐碎的思绪
查看>>
shell 3数组
查看>>
29个简单直观的移动设备网页设计
查看>>
webform(七)分页
查看>>
中国互联网的十一种盈利模式
查看>>
php中$_REQUEST、$_POST、$_GET的区别和联系小结
查看>>
看了极光推送技术原理的几点思考
查看>>
【转】Vue.js 2.0 快速上手精华梳理
查看>>
【题解】BZOJ 3065: 带插入区间K小值——替罪羊树套线段树
查看>>
OpenCV矩阵运算
查看>>
CF 567D(One-Dimensional Battle Ships-二分)
查看>>
从设计到实现,一步步教你实现Android-Universal-ImageLoader-辅助类
查看>>
redis 安装启动及设置密码windows
查看>>
python 生成验证码
查看>>
从零开始用 Flask 搭建一个网站(二)
查看>>
leetcode-93-复原ip地址
查看>>
RAID详解[RAID0/RAID1/RAID10/RAID5]
查看>>