【问题标题】:How to create popup image slider?如何创建弹出图像滑块?
【发布时间】:2017-05-13 22:04:08
【问题描述】:

由于我是 javascript 新手,我不知道如何制作弹出图像滑块。图像不应显示在原始 html 页面上,只能在弹出窗口中显示。有人可以概述我应该遵循的步骤作为指导以达到这种效果吗?新手复杂吗?

感谢您的建议。

【问题讨论】:

  • 到目前为止您尝试过什么? SO 不是“为我编写代码”网站,我们将尽力帮助您解决有关您正在使用的代码的问题。
  • 你基本上想要一个包含图像的弹出窗口,对吧?
  • kdyz:是的,没错。
  • Carsten Løvbo Andersen:我并不是说任何人都应该为我编写代码。只需概述如下步骤:创建覆盖 div,然后创建此等等......我基本上没有通过覆盖 div 哈哈。

标签: javascript jquery css


【解决方案1】:

这是您尝试做的工作示例,只需要编辑/添加图像和文本。希望这会有所帮助!

<!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/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Basic Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <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="http://lorempixel.com/400/575/technics/3" alt="...">
      <div class="carousel-caption">
        ...
      </div>
    </div>
    <div class="item">
      <img src="http://lorempixel.com/400/575/technics/3" 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>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

</body>
</html>

【讨论】:

    【解决方案2】:

    我建议你使用Bootstrap Framework

    基本上,您需要两件事:一个弹出框和一个轮播。

    对于弹出窗口:

    http://getbootstrap.com/javascript/#modals

    里面的旋转木马:

    http://getbootstrap.com/javascript/#carousel

    这是最简单且最具扩展性的方法。希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 2013-07-30
      • 2014-04-15
      相关资源
      最近更新 更多