Loading carousel slide from left to right

Hi I am using bootstrap and created a bootstrap carousel but I want it to move from left to right.

this is my code on jsfiddle

in this code the carousel moves from right to left

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

      

i changed left and left in var, but there is a problem. the next slide will reappear on the right.

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

IX changed everything left and right in the .carousel class in bootstrap.css

+3


source to share


4 answers


Bootstrap cassette with 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);
              }
            }

      

+1


source


You can try changing your HTML code. carousel-control

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

      

to



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

      

:)

0


source


I also modified .bootstrap css to achieve this effect. Instead of swapping all left for right in css, I changed this line in the inner_carousel class:

"6s ease in leaving the left;" up to "6s ease of handling";

In addition, I've changed all calls from "100%" to "-100%" and "100%" to "-100%" in all of the inner_carousel child classes.

0


source


In 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 the following 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');
}

      

0


source







All Articles