Bootstrap carousel slide left to right

天大地大妈咪最大 提交于 2019-12-10 10:11:27

问题


Hi i using bootstrap and created bootstrap carousel but i want it move from left to the right

this is my code on jsfiddle

on this code carousel move from right to the left

var direction = type == 'next' ? 'left' : 'right'

i changed right and left in var but there is a problem. next slide come in from right again

var direction = type == 'next' ? 'right' : 'left'

I hope you understand what i want :D

EDIT:

Finally I found the answer: I edited the twitter bootstrap.css

I Xchanged all left and right in .carousel class in bootstrap.css


回答1:


You can try to change in .carousel-control html code

data-slide="prev"
data-slide="next"

to

data-slide="next" 
data-slide="prev"     

:)




回答2:


Bootstrap carousel by CSS only (right to left, RTL) HTML:

        <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="..." alt="...">
              <div class="carousel-caption">
                ...
              </div>
            </div>
            <div class="item">
              <img src="..." 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>

CSS:

                /* Make the images wide and responsive. */
            #myCarousel img {
              height: auto;
              max-width: 100%;
              width: 100%;
            }

            /* Change the order of the indicators. 
               Return them to the center of the slide. */
            .carousel-indicators {
              width: auto;
              margin-left: 0;
              transform: translateX(-50%);
            }
            .carousel-indicators li {
              float: right;
              margin: 1px 4px;
            }
            .carousel-indicators .active {
              margin: 0 3px;
            }

            /* Change the direction of the transition. */
            @media all and (transform-3d), (-webkit-transform-3d) {
              .carousel-inner > .item.next,
              .carousel-inner > .item.active.right {
                left: 0;
                -webkit-transform: translate3d(-100%, 0, 0);
                transform: translate3d(-100%, 0, 0);
              }
              .carousel-inner > .item.prev,
              .carousel-inner > .item.active.left {
                left: 0;
                -webkit-transform: translate3d(100%, 0, 0);
                transform: translate3d(100%, 0, 0);
              }
            }



回答3:


I also altered the .bootstrap css to achieve this effect. Instead of exchanging all lefts to rights in the css, I altered this line in the inner_carousel class:

"6s ease-in-out left;" to "6s ease-in-out right;"

Additionally, I swapped any calls of "100%" to "-100%" and "100%" to "-100%" in all child classes of the inner_carousel class.




回答4:


In the Bootstrap v3.3.7 find the 'bootstrap.js' file

Now, find this code :

var delta = direction == 'prev' ? -1 : 1;

change it to :

var delta = direction == 'prev' ? 1 : -1;

Then, find these lines :

Carousel.prototype.next = function () {
    if (this.sliding)
        return
    return this.slide('next');
}

Carousel.prototype.prev = function () {
    if (this.sliding)
        return
    return this.slide('prev');
}

and change that to :

Carousel.prototype.next = function () {
    if (this.sliding)
        return
    return this.slide('prev');
}

Carousel.prototype.prev = function () {
    if (this.sliding)
        return
    return this.slide('next');
}


来源:https://stackoverflow.com/questions/29962585/bootstrap-carousel-slide-left-to-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!