如何添加链接到滑块的导航子弹?

时间:2015-11-01 17:53:00

标签: navigation slider

你好我有一些滑块的工作代码我想知道如何添加子弹导航我可以实际添加,但是?在javascript代码ul lyst是混合的,这是子弹的问题,不要正确跟踪幻灯片...这里是链接到代码



jQuery(document).ready(function ($) {

    //set vars for slider size
    var slideCount = $('#slider ul li').length;
    var slideWidth = $('#slider ul li').width();
    var slideHeight = $('#slider ul li').height();
    var sliderUlWidth = slideCount * slideWidth;

    $('#slider').css({
        width: slideWidth,
        height: slideHeight
    });

    $('#slider ul').css({
        width: sliderUlWidth,
        marginLeft: -slideWidth
    });

    $('#slider ul li:last-child').prependTo('#slider ul');
    //move left function (prev)
    function moveLeft() {
        $('#slider ul').animate({
            left: +slideWidth
        }, 700, function () {
            $('#slider ul li:last-child').prependTo('#slider ul');
            $('#slider ul').css('left', '');
        });
    };
    //move right function (next)
    function moveRight() {
        $('#slider ul').animate({
            left: -slideWidth
        }, 700, function () {
            $('#slider ul li:first-child').appendTo('#slider ul');
            $('#slider ul').css('left', '');
        });
    };
    // call functions on click 
    $('a.control_prev').click(function () {
        moveLeft();
    });

    $('a.control_next').click(function () {
        moveRight();
    });

});

@import url(http://fonts.googleapis.com/css?family=Open+Sans:400, 300, 600);
 html {
    border-top: 5px solid #fff;
    color: #2a2a2a;
}
html, body {
    margin: 0;
    padding: 0;
    font-family:'Open Sans';
    background-color: #F6F6F6;
}
h1 {
    color: #00AAE1;
    text-align: center;
    font-weight: 300;
}
#slider {
    position: relative;
    overflow: hidden;
    margin: 20px auto 0 auto;
    border: 1px solid #999;
    -moz-box-shadow: 0 0 3px 3px #aaaaaa;
    -webkit-box-shadow: 0 0 3px 3px#aaaaaa;
    box-shadow: 0 0 3px 3px #aaaaaa;
}
#slider ul {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}
#slider ul li {
    position: relative;
    display: block;
    float: left;
    margin: 0;
    padding: 0;
    width: 906px;
    height: 550px;
    background: #fff;
    text-align: center;
    line-height: 300px;
}
a.control_prev, a.control_next {
    position: absolute;
    top: 40%;
    z-index: 999;
    display: block;
    padding: 4% 3%;
    width: auto;
    height: auto;
    background: #4AC8E9;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 18px;
    opacity: 0.5;
    cursor: pointer;
}
a.control_prev:hover, a.control_next:hover {
    opacity: 1;
    -webkit-transition: all 0.2s ease;
}
a.control_prev {
    border-radius: 0 20px 20px 0;
}
a.control_next {
    right: 0;
    border-radius: 20px 0 0 20px;
}
.slider_option {
    position: relative;
    margin: 10px auto;
    width: 200px;
    font-size: 16px;
}
.footer {
    width: 300px;
    margin: 0 auto;
    margin-top: 100px;
    font-size: 9pt;
    text-align: center;
    font-family: arial;
}

<htmL>
<head>
        <title>SME's</title>
        <link rel="stylesheet" href="presStyle.css" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    </head>
    
    <body>
        
<h1><span style="color: #333;">Broadband</span></h1>

        <div id="slider"> <a href="#" class="control_next">></a>
 <a href="#" class="control_prev"><</a>

            <ul>
                <li>slide1</li>
                <li>slide2</li>
                <li>slide3</li>
                <li class="final">slide4</li>
            </ul>
        </div>
        <div class="footer"></div>
        <script src="sliderJQ.js"></script>
    </body>

</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案