无法获取unslider的演示代码

时间:2013-11-01 10:36:38

标签: jquery

我正在尝试遵循http://unslider.com/上的说明,但我无法让它发挥作用。

这就是我所拥有的,没有任何显示。

<html>
<head>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="http://unslider.com/unslider.min.js"></script>

    <style>
        .banner { position: relative; overflow: auto; }
        .banner li { list-style: none; }
            .banner ul li { float: left; }
    </style>
</head>
<body>

    <div class="banner">
        <ul>
            <li>This is a slide.</li>
            <li>This is another slide.</li>
            <li>This is a final slide.</li>
        </ul>
    </div>


    <script>
            $(function() {
                $('.banner').unslider();
            });
    </script>
</body>
</html>

4 个答案:

答案 0 :(得分:4)

如果要查看某些图像,请添加一些图像

<html>
<head>
<style>
.banner { position: relative; overflow: auto; }
    .banner li { list-style: none; }
        .banner ul li { float: left; }
</style>

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://unslider.com/unslider.min.js"></script>
<script>
$(function() {
    $('.banner').unslider();
});
</script>
</head>
<body>
<div class="banner">
    <ul>
        <li><img src="http://cdn.arstechnica.net/wpcontent/uploads/2012/10/06_Place_20773_1_Mis.jpg"></li>
        <li><img src="http://s3.firstpost.in/wp-content/uploads/2012/11/300vsSA-Getty.jpg"></li>

    </ul>
</div>
</body>

答案 1 :(得分:3)

因为您的代码中没有添加任何css,原始方面已添加了以下css

http://unslider.com/style.css

Check this working example.

答案 2 :(得分:1)

检查这个很好的教程!

http://www.youtube.com/watch?v=qBOB9scHnwo

  1. 您需要包含脚本

    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="http://unslider.com/unslider.min.js"></script>
    
  2. 横幅div的样式

    <style>
        .banner {
            position: relative;
            width: 100%;
            overflow: auto;
            padding: 0px;
            margin: 0px;
        }
        .banner ul {
            padding: 0px;
            margin: 0px;
        }
        .banner li{
        padding: 0px;
        margin: 0px;
        }
        .banner ul li {
            float:left;
            padding: 0px;
            margin: 0px;
            min-height: 200px;
            -webkit-background-size: 100% auto;
            -moz-background-size: 100% auto;
            -o-background-size: 100% auto;
            -ms-background-size: 100% auto;
            background-size: 100% auto;
            background-position-y: -75px;
            box-shadow: inset 0 -3px 6px rgba(0,0,0,.1);
        }
    </style>
    
  3. 并启动unslider

    <script>
        $(document).ready(function(){
            $('.banner').unslider({
            speed: 500,               //  The speed to animate each slide (in milliseconds)
            delay: 3000,              //  The delay between slide animations (in milliseconds)
            complete: function() {},  //  A function that gets called after every slide animation
            keys: true,               //  Enable keyboard (left, right) arrow shortcuts
            dots: true,               //  Display dot navigation
            fluid: true              //  Support responsive design. May break non-responsive designs
            });
         });
    </script>
    

答案 3 :(得分:0)

可能你错过了CSS样式。将其放入<head>

<style>
    @import url("http://unslider.com/style.css");
    .banner { position: relative; overflow: auto; }
    .banner li { list-style: none; }
    .banner ul li { float: left; }
</style>

JSBIN