carousel

<!DOCTYPE html>
<html lang="en" ng-app="mainApp">
<head>
<meta charset="utf-8">
<!-- add styles -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!-- add javascripts -->
<!-- <script src="js/jquery-2.1.3.min.js"></script> 不需要 -->
<script src="js/angular.min.js"></script>
<script src="js/angular-animate.min.js"></script>
<script src="js/angular-touch.min.js"></script>
<script src="js/app.js"></script>
<title>carousel</title>
</head>
<body ng-controller="MainCtrl">
    <header>
        <a href="http://www.script-tutorials.com/demos/366/index.html" class="logo">
            <!-- <img src="images/logo.png" /> -->
        </a>
    </header>

    <!-- slider container -->
    <div class="container slider">

        <!-- enumerate all photos -->
        <img ng-repeat="photo in photos" class="slide" ng-swipe-right="showPrev()" ng-swipe-left="showNext()" ng-show="isActive($index)" ng-src="{{photo.src}}" />

        <!-- prev / next controls -->
        <a class="arrow prev" href="#" ng-click="showPrev()"></a>
        <a class="arrow next" href="#" ng-click="showNext()"></a>

        <!-- extra navigation controls -->
        <ul class="nav">
            <li ng-repeat="photo in photos" ng-class="{‘active‘:isActive($index)}">
                <img ng-src="{{photo.src}}" alt="{{photo.desc}}" title="{{photo.desc}}" ng-click="showPhoto($index);" />
            </li>
        </ul>

    </div>
</body>
</html>
*{margin: 0; padding: 0; border: none;}
.arrow{cursor: pointer; display: block; height: 64px; margin-top: -35px; outline: medium none; position: absolute; top: 50%; width: 64px; z-index: 5;}
.arrow.prev{/*background-image: url("../images/prev.png");*/ left: 20px; opacity: 0.2; transition: all 0.2s linear 0s;}
.arrow.next{/*background-image: url("../images/next.png");*/ opacity: 0.2; right: 20px; transition: all 0.2s linear 0s;}
.arrow.prev:hover{opacity:1;}
.arrow.next:hover{opacity:1;}
.nav{bottom: -4px; display: block; height: 48px; left: 0; margin: 0 auto; padding: 1em 0 0.8em; position: absolute; right: 0; text-align: center; width: 100%; z-index: 5;}
.nav li{border: 5px solid #AAAAAA; border-radius: 5px; cursor: pointer; display: inline-block; height: 30px; margin: 0 8px; position: relative; width: 50px;}
.nav li.active{border: 5px solid #FFFFFF;}
.nav li img{width: 100%;}
.slider{border: 15px solid #FFFFFF; border-radius: 5px; height: 500px; margin: 20px auto; position: relative; width: 800px; -webkit-perspective: 1000px; -moz-perspective: 1000px; -ms-perspective: 1000px; -o-perspective: 1000px; perspective: 1000px; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -ms-transform-style: preserve-3d; -o-transform-style: preserve-3d; transform-style: preserve-3d;}
.slide{position: absolute; top: 0; left: 0;}
.slide.ng-hide-add{opacity:1; -webkit-transition:1s linear all; -moz-transition:1s linear all; -o-transition:1s linear all; transition:1s linear all; -webkit-transform: rotateX(50deg) rotateY(30deg); -moz-transform: rotateX(50deg) rotateY(30deg); -ms-transform: rotateX(50deg) rotateY(30deg); -o-transform: rotateX(50deg) rotateY(30deg); transform: rotateX(50deg) rotateY(30deg); -webkit-transform-origin: right top 0; -moz-transform-origin: right top 0; -ms-transform-origin: right top 0; -o-transform-origin: right top 0; transform-origin: right top 0;}
.slide.ng-hide-add.ng-hide-add-active{opacity:0;}
.slide.ng-hide-remove{-webkit-transition:1s linear all; -moz-transition:1s linear all; -o-transition:1s linear all; transition:1s linear all; display:block!important; opacity:0;}
.slide, .slide.ng-hide-remove.ng-hide-remove-active{opacity:1;}
var mainApp = angular.module(‘mainApp‘, [‘ngAnimate‘, ‘ngTouch‘]);

mainApp.controller(‘MainCtrl‘, function ($scope) {
    // Set of Photos
    $scope.photos = [
        {src: ‘/carouseldemo/images/1.jpg‘, desc: ‘Image 01‘},
        {src: ‘/carouseldemo/images/2.jpg‘, desc: ‘Image 02‘},
        {src: ‘/carouseldemo/images/3.jpg‘, desc: ‘Image 03‘},
        {src: ‘/carouseldemo/images/4.jpg‘, desc: ‘Image 04‘},
        {src: ‘/carouseldemo/images/5.jpg‘, desc: ‘Image 05‘},
        {src: ‘/carouseldemo/images/6.jpg‘, desc: ‘Image 06‘}
    ];

    // initial image index
    $scope._Index = 0;

    // if a current image is the same as requested image
    $scope.isActive = function (index) {
        return $scope._Index === index;
    };

    // show prev image
    $scope.showPrev = function () {
        $scope._Index = ($scope._Index > 0) ? --$scope._Index : $scope.photos.length - 1;
    };

    // show next image
    $scope.showNext = function () {
        $scope._Index = ($scope._Index < $scope.photos.length - 1) ? ++$scope._Index : 0;
    };

    // show a certain image
    $scope.showPhoto = function (index) {
        $scope._Index = index;
    };
});

转载请备注。

时间: 2024-10-06 08:08:04

carousel的相关文章

Bootstrap 之 Carousel

Bootstrap 轮播(Carousel)插件是一种灵活的响应式的向站点添加滑块的方式.除此之外,内容也是足够灵活的,可以是图像.内嵌框架.视频或者其他您想要放置的任何类型的内容. 如果您想要单独引用该插件的功能,那么您需要引用 carousel.js.或者,正如 Bootstrap 插件概览 一章中所提到,您可以引用 bootstrap.js 或压缩版的 bootstrap.min.js. 下面是一个简单的幻灯片,使用 Bootstrap 轮播(Carousel)插件显示了一个循环播放元素的

Bootstrap 轮播(Carousel)插件

Bootstrap 轮播(Carousel)插件是一种灵活的响应式的向站点添加滑块的方式.除此之外,内容也是足够灵活的,可以是图像.内嵌框架.视频或者其他您想要放置的任何类型的内容. 如果您想要单独引用该插件的功能,那么您需要引用 carousel.js.或者,正如 Bootstrap 插件概览 一章中所提到,您可以引用bootstrap.js 或压缩版的 bootstrap.min.js. 实例 下面是一个简单的幻灯片,使用 Bootstrap 轮播(Carousel)插件显示了一个循环播放元

Bootstrap历练实例:轮播(carousel)

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible"content="IE=edge" /> <meta name="viewport"

Bootstrap carousel轮转图的使用

演示效果截图: 代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <style> body { padding:

bootstrap插件学习-bootstrap.carousel.js

先看bootstrap.carousel.js的结构 var Carousel = function (element, options){} //构造器 Carousel.prototype = {} // 构造器原型 $.fn.carousel = function ( option ) {} //jQuery原型上自定义的方法 $.fn.carousel.defaults ={} //默认参数 $.fn.carousel.Constructor = Carousel // 重写jQuery

Bootstrap轮播Carousel样式的应用

<h3>bootstrap轮播效果</h3> <div id="myCarousel" class="carousel slide" style="width:300px;"> <!--轮播指南--> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-sli

jetty+bootstrap Carousel+springMVC+mybatis实现表格数据的轮播

index.jsp <%@ page language="java" pageEncoding="UTF-8"%> <%@include file="/taglibs.jsp"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd&quo

bootstrap源码分析之Carousel

源码文件: Carousel.scssCarousel.js 实现原理: 隐藏所有要显示的元素,然后指定当前要显示的为block,宽.高自适应 源码分析: 1.Html结构:主要分为以四个部分  1.1.容器:最外层div,需要一个data-ride="carousel"来指定为轮播放插件,并且提供一个Id,方便圆圈指示符的关联  1.2.图片列表部分,用一个外层div包裹所有,然后每个img会被一个div,则class为item的包裹住  1.3.圆圈指示符:用一个ol列表来显示其各

Bootstrap的js插件之轮播(carousel)

轮播请查看以下示例,基本已经涵盖最常用的一个轮播 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>js插件_轮播</titl

Bootstrap 轮播图(Carousel)插件

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>demo</title> <link rel="icon" type="image/x-icon" href="../img/favicon.ico"/> <script type