第二个旋转木马不起作用

时间:2015-07-25 04:59:29

标签: jquery html css twitter-bootstrap

我刚刚在我的网站上添加了第二个轮播,但不幸的是,由于不明原因它只是堆叠 - 意味着没有滑动,箭头无效。我做了什么,我只是复制了我的第一个正确的工作旋转木马并将其放入页面下方。可能有什么不对?在html代码中以注释标记的第一个和第二个轮播。

的CSS:

.jumbotron {
    position: relative;
    background: #000 url('35.jpg') center center no-repeat;
    width: 100%;
    background-size: cover;
    overflow: hidden;
    height: 370px;
    padding-bottom: 1px;
}

.navbar .nav > li > a {
    text-decoration: none;
    color:  white;
    font-size:15px;
    font-family: Arial, sans-serif;
    text-align: center; 
    font-weight: bold;
}

#brand-image
{
height:30px;
margin-top: 1px;
}

#features
{
padding-top: 50px;
}

#gallery
{
padding-top: 50px;
}

#feedback
{
padding-top: 50px;
}

#faq
{
padding-top: 50px;
}



    /* CUSTOMIZE THE CAROUSEL
    -------------------------------------------------- */

    /* Carousel base class */
    .carousel {
      margin-bottom: -90px;             /* odstep miedzy carusel slider a nastepnym containerem tzn O mnie */
    }

    .carousel .container {
      position: relative;
      z-index: 9;
    }

    .carousel-control {
      height: 80px;
      margin-top: 0;
      font-size: 120px;
      text-shadow: 0 1px 1px rgba(0,0,0,.4);
      background-color: transparent;
      border: 0;
      z-index: 10;
    }

    .carousel .item {
      height: 550px;
    }
    .carousel img {
      position: absolute;
      top: 0;
      left: 0;
      min-width: 100%;
      height: 500px;


    }

    .carousel-caption {
      background-color: transparent;
      position: static;
      max-width: 550px;
      padding: 0 20px;
      margin-top: 200px;
    }
    .carousel-caption h1,
    .carousel-caption .lead {
      margin: 0;
      line-height: 1.25;
      color: #fff;
      text-shadow: 0 1px 1px rgba(0,0,0,.4);
    }
    .carousel-caption .btn {
      margin-top: 10px;
    }



    /* MARKETING CONTENT
    -------------------------------------------------- */

    /* Center align the text within the three columns below the carousel */
    .marketing .span4 {
      text-align: center;
    }
    .marketing h2 {
      font-weight: normal;
    }
    .marketing .span4 p {
      margin-left: 10px;
      margin-right: 10px;
    }


    /* Featurettes
    ------------------------- */

    .featurette-divider {
      margin: 80px 0; /* Space out the Bootstrap <hr> more */
    }
    .featurette {
      padding-top: 120px; /* Vertically center images part 1: add padding above and below text. */
      overflow: hidden; /* Vertically center images part 2: clear their floats. */
    }
    .featurette-image {
      margin-top: -120px; /* Vertically center images part 3: negative margin up the image the same amount of the padding to center it. */
    }

    /* Give some space on the sides of the floated elements so text doesn't run right into it. */
    .featurette-image.pull-left {
      margin-right: 40px;
    }
    .featurette-image.pull-right {
      margin-left: 40px;
    }

    /* Thin out the marketing headings */
    .featurette-heading {
      font-size: 50px;
      font-weight: 300;
      line-height: 1;
      letter-spacing: -1px;
    }



    /* RESPONSIVE CSS
    -------------------------------------------------- */

    @media (max-width: 979px) {

      .container.navbar-wrapper {
        margin-bottom: 0;
        width: auto;
      }
      .navbar-inner {
        border-radius: 0;
        margin: -20px 0;
      }

      .carousel .item {
        height: 500px;
      }
      .carousel img {
        width: auto;
        height: 500px;
      }

      .featurette {
        height: auto;
        padding: 0;
      }
      .featurette-image.pull-left,
      .featurette-image.pull-right {
        display: block;
        float: none;
        max-width: 40%;
        margin: 0 auto 20px;
      }
    }


    @media (max-width: 767px) {

      .navbar-inner {
        margin: -20px;
      }

      .carousel {
        margin-left: -20px;
        margin-right: -20px;
      }
      .carousel .container {

      }
      .carousel .item {
        height: 300px;
      }
      .carousel img {
        height: 300px;
      }
      .carousel-caption {
        width: 65%;
        padding: 0 70px;
        margin-top: 100px;
      }
      .carousel-caption h1 {
        font-size: 30px;
      }
      .carousel-caption .lead,
      .carousel-caption .btn {
        font-size: 18px;
      }

      .marketing .span4 + .span4 {
        margin-top: 40px;
      }

      .featurette-heading {
        font-size: 30px;
      }
      .featurette .lead {
        font-size: 18px;
        line-height: 1.5;
      }

    }

HTML:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>My Logo</title>
    <meta name="description" content="Wiredwiki App">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">


    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
    <link rel="stylesheet" type="text/css" href="custom.css">
</head>

    <style>
    body{
        padding-top: 50px;
    }
    </style>



<body data-spy="scroll" data-target="#my-navbar">

  <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
    <a class="navbar-brand" href="#">
        <!--<img id="brand-image" alt="Website Logo" src="111.png" /> -->
        <a class="navbar-brand" href="#"></a>
    </a>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                   <li><a href="#feedback"><span class="glyphicon glyphicon-user"></span> O MNIE</a> 
                    <li><a href="#gallery"><span class="glyphicon glyphicon-credit-card"></span> blabla</a> 
                    <li><a href="#features"><span class="glyphicon glyphicon-th-large"></span> blabla</a> 
                    <li><a href="#faq"><span class="glyphicon glyphicon-headphones"></span> blabla</a> 
                    <li><a href="#contact"><span class="glyphicon glyphicon-earphone"></span>KONTAKT</a> 
                </ul>
            </div>
        </div>
    </div>

<!-- FIRST CAROUSEL -->

    <div class="carousel slide" id="myCarousel">
      <div class="carousel-inner">
        <div class="item active">
          <img src="new/3.jpg">
          <div class="container">
            <div class="carousel-caption">
              <h1>Example headline.</h1>
              <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
              <a class="btn btn-large btn-primary" href="#">Sign up today</a>
            </div>
          </div>
        </div>
        <div class="item">
          <img alt="" src="new/1.jpg">
          <div class="container">
            <div class="carousel-caption">
              <h1>Another example headline.</h1>
              <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
              <a class="btn btn-large btn-primary" href="#">Learn more</a>
            </div>
          </div>
        </div>
        <div class="item">
          <img alt="" src="new/2.jpg">
          <div class="container">
            <div class="carousel-caption">
              <h1>One more for good measure.</h1>
              <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
              <a class="btn btn-large btn-primary" href="#">Browse gallery</a>
            </div>
          </div>
        </div>
      </div>
      <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
      <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
    </div><!-- /.carousel -->

    <!--
    <div class="jumbotron">
        <div class="container">
        </div>
        </div>-->


    <!-- Feedback-->
    <div class="container" id="moj">
        <section>
            <div class="page-header" id="feedback">
                <h2>Kilka słów o mnie.<small> couple words about myself</small></h2>
            </div>

            <div class="row">
                <div class="col-md-4">
                    <blockquote>
                        <p>blabla</p>
                        <footer>blabla</footer>
                    </blockquote>
                </div>
                <div class="col-md-4">
                    <blockquote>
                        <p>blabla</p>
                        <footer>blabla
</footer>
                    </blockquote>
                </div>
                <div class="col-md-4">
                    <blockquote>
                        <p>blabla</p>
                        <footer>blabla
</footer>
                    </blockquote>
                </div>
            </div><!-- End row -->
        </section>
    </div><!--End Container-->

<!-- call to action -->
    <section>
        <div class="well">
            <div class="container text-center">
                <h3><i>blabla</i></h3>
                <p><i>blabla<i></p>




            </div><!-- end Container-->

        </div><!-- end well-->
    </section><!-- Call to action -->

<!-- Gallery -->
    <div class="container">
        <section>
            <div class="page-header" id="gallery">
                <h2>bla<small> Couple of already realased projects.</small></h2>
            </div>
                </section>
    </div>

<!-- SECOND CAROUSEL -->

            <div class="carousel slide" id="myCarousel">
      <div class="carousel-inner">
        <div class="item active">
          <img src="projekty/hotel/1.png">
          <div class="container">
            <div class="carousel-caption">
              <h1>Example headline.</h1>
              <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
              <a class="btn btn-large btn-primary" href="#">Sign up today</a>
            </div>
          </div>
        </div>
        <div class="item">
          <img alt="" src="projekty/hotel/1.png">
          <div class="container">
            <div class="carousel-caption">
              <h1>Another example headline.</h1>
              <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
              <a class="btn btn-large btn-primary" href="#">Learn more</a>
            </div>
          </div>
        </div>
        <div class="item">
          <img alt="" src="projekty/hotel/3.png">
          <div class="container">
            <div class="carousel-caption">
              <h1>One more for good measure.</h1>
              <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
              <a class="btn btn-large btn-primary" href="#">Browse gallery</a>
            </div>
          </div>
        </div>
      </div>
      <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
      <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
    </div><!-- /.carousel -->

编辑:

第二个carusel:

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="projekty/hotel/3.png" alt="">
      <div class="carousel-caption">
        ...
      </div>
    </div>
    <div class="item">
      <img src="projekty/hotel/1.png" alt="">
      <div class="carousel-caption">
      </div>
    </div>
    <div class="item">
      <img src="projekty/hotel/2.png" alt="">
      <div class="carousel-caption">
      </div>
    </div>

  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

3 个答案:

答案 0 :(得分:0)

id“myCarousel”使用两次,使它们独一无二。它会起作用。

答案 1 :(得分:0)

您需要创建唯一ID并更改您的轮播js并为其他ID创建设置。以下是使用bootstrap Carousel multiple sliders with bootstrap

的示例

答案 2 :(得分:0)

也可以为轮播div和JQUERY脚本使用不同的ID

$(document).ready(function() {

  $("#USE_DIFFERENT_ID_1").owlCarousel();
  $("#USE_DIFFERENT_ID_2").owlCarousel();

});