0

在我的頁面中,我在該輪播中有一個輪播和四個項目。在一個項目中滾動會影響自舉輪播中的另一個項目

所有項目都有一些大的列表,並且在一個項目中滾動會自動滾動其他項目。

我不希望其他項目自動滾動,他們應該在他們的位置,直到滾動,如何做到這一點?

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <title>Bootstrap Example</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 
    <style> 
 
    .carousel-inner > .item > img, 
 
    .carousel-inner > .item > a > img { 
 
     width: 70%; 
 
     margin: auto; 
 
    } 
 
    </style> 
 
</head> 
 
<body> 
 

 
<div class="container"> 
 
    <br> 
 
    <div id="myCarousel" class="carousel" > 
 
    <!-- Indicators --> 
 
    <ol class="carousel-indicators"> 
 
     <li data-target="#myCarousel" data-slide-to="0" class="active"></li> 
 
     <li data-target="#myCarousel" data-slide-to="1"></li> 
 
     <li data-target="#myCarousel" data-slide-to="2"></li> 
 
     <li data-target="#myCarousel" data-slide-to="3"></li> 
 
    </ol> 
 

 
    <!-- Wrapper for slides --> 
 
    <div class="carousel-inner" role="listbox"> 
 
     <div class="item active"> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p>   
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     </div> 
 

 
     <div class="item"> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     </div> 
 
    
 
     <div class="item"> 
 
      <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p>    
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item3</p> 
 
     <p>Item 3</p> 
 
     <p>Item3</p> 
 
     </div> 
 

 
     <div class="item"> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     </div> 
 
    </div> 
 

 
    <!-- Left and right controls --> 
 
    <a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next"> 
 
     <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> 
 
     <span class="sr-only">Next</span> 
 
    </a> 
 
    </div> 
 
</div> 
 

 
</body> 
 
</html>

回答

2

這是因爲你在滾動網頁上,而不是內部的旋轉木馬......

這裏有一種方法,只需要設置一個max-height至轉盤項目。

CSS

.carousel .item {max-height:300px;overflow:auto;} 

Bootplyhttp://www.bootply.com/c0k8PpJ6PP


<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <title>Bootstrap Example</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 
    <style> 
 
    .carousel-inner > .item > img, 
 
    .carousel-inner > .item > a > img { 
 
     width: 70%; 
 
     margin: auto; 
 
    } 
 
    .carousel .item {max-height:300px;overflow:auto;} 
 
    </style> 
 
</head> 
 
<body> 
 

 
<div class="container"> 
 
    <br> 
 
    <div id="myCarousel" class="carousel" > 
 
    <!-- Indicators --> 
 
    <ol class="carousel-indicators"> 
 
     <li data-target="#myCarousel" data-slide-to="0" class="active"></li> 
 
     <li data-target="#myCarousel" data-slide-to="1"></li> 
 
     <li data-target="#myCarousel" data-slide-to="2"></li> 
 
     <li data-target="#myCarousel" data-slide-to="3"></li> 
 
    </ol> 
 

 
    <!-- Wrapper for slides --> 
 
    <div class="carousel-inner" role="listbox"> 
 
     <div class="item active"> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p>   
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     <p>Item 1</p> 
 
     </div> 
 

 
     <div class="item"> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item 2</p> 
 
     <p>Item2</p> 
 
     </div> 
 
    
 
     <div class="item"> 
 
      <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p>    
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item 3</p> 
 
     <p>Item3</p> 
 
     <p>Item 3</p> 
 
     <p>Item3</p> 
 
     </div> 
 

 
     <div class="item"> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     <p>Item 4</p> 
 
     </div> 
 
    </div> 
 

 
    <!-- Left and right controls --> 
 
    <a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next"> 
 
     <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> 
 
     <span class="sr-only">Next</span> 
 
    </a> 
 
    </div> 
 
</div> 
 

 
</body> 
 
</html>

+0

哇,這是偉大的 –

相關問題