小编Sye*_*har的帖子

如何在单击轮播的下一个或上一个 btn 时停止滚动顶部?

以下是使用中的简单轮播,即使它在编码中看起来不错,但是在浏览器上每当尝试单击nextprev按钮时,页面都 scrolled在 HTML 的顶部。

<!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="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  .carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
      width: 70%;
      margin: auto;
  }
  </style>
</head>
<body>
<h1>SAMPLE CONTENT HERE</h1>
    <h1>SAMPLE CONTENT HERE</h1>
    <h1>SAMPLE CONTENT HERE</h1>
    <h1>SAMPLE CONTENT HERE</h1>
<div class="container">
  <br>
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li> …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery carousel twitter-bootstrap

3
推荐指数
1
解决办法
1851
查看次数

标签 统计

carousel ×1

html ×1

javascript ×1

jquery ×1

twitter-bootstrap ×1