twitter-bootstrap - Bootstrap 开关的问题

标签 twitter-bootstrap css button twitter-bootstrap-3

我正在尝试使用 Bootstrap 开关,但遇到了一些问题。我在这里使用这个例子 http://www.jque.re/plugins/version3/bootstrap.switch/无论我使用什么类,按钮都保持相同的样式和非常小的尺寸,我什至看不到 ON 和 OFF 文本。我真的不知道我做错了什么。有什么帮助吗?谢谢

这是我的html:

<!DOCTYPE html>
<html lang="pt">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="css/jquery-ui-1.10.1.custom.css" />
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-switch.css" rel="stylesheet">
    <link href="css/_custom.css" rel="stylesheet">   

    <script src="js/jquery-1.9.1.js" type="text/javascript"></script>
    <script src="js/jquery-ui.js" type="text/javascript"></script>
    <script src="js/bootstrap-switch.js"></script>


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body> 
         <div class="row">
    <div class="col-lg-12">
<div class="make-switch switch-large">
    <input type="checkbox" name="my-checkbox" checked>

    <div class="make-switch" data-on="primary" data-off="info">
    <input type="checkbox" checked name="my-checkbox">

    <div id="label-switch" class="make-switch" data-on-label="SIM" data-off-label="NÃO">
    <input type="checkbox" checked name="my-checkbox">
</div>
</div>
</div>
</div></div>

  </form>

</div>  
    <script type="text/javascript">
$("[name='my-checkbox']").bootstrapSwitch();
</script>



    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>

  </body>
</html>

最佳答案

您的依赖项出现故障;他们应该是这样的。

标题

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.min.css" rel="stylesheet" />
<link href="path/custom.css" rel="stylesheet" type="text/css"/>

body 的尽头
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js"></script>
<script>$("[name='my-checkbox']").bootstrapSwitch();</script>

CSS 订单
  • Bootstrap CSS
  • Boostrap 开关 CSS
  • 自定义 CSS

  • JS 订购
  • jQuery
  • Bootstrap JS
  • Bootstrap 开关 JS

  • 您还在页面上加载了 jQuery 两次,(一次在您的头部,一次在正文的末尾)在所有 JS 依赖项之前使用一次。
    $("[name='my-checkbox']").bootstrapSwitch();还需要放在所有其他 JS 依赖项之后才能加载。

    **旁注:您缺少一个开口form标记为好。

    $("[name='my-checkbox']").bootstrapSwitch();
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.min.css" rel="stylesheet" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js"></script>
    <hr>
    <form>
      <div class="container">
        <div class="row">
          <div class="col-lg-12">
            <div class="make-switch switch-large">
              <input type="checkbox" name="my-checkbox" checked>
              <div class="make-switch" data-on="primary" data-off="info">
                <input type="checkbox" checked name="my-checkbox">
                <div id="label-switch" class="make-switch" data-on-label="SIM" data-off-label="NÃO">
                  <input type="checkbox" checked name="my-checkbox">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </form>

    关于twitter-bootstrap - Bootstrap 开关的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32680559/

    相关文章:

    javascript - 使用 AngularJS 如何在 Accordion 中显示新数据而不重新加载页面

    html - Bootstrap 粘性页脚存在小宽度页面的问题

    css - Bootstrap Carousel 推送和拉取内容

    javascript - Amcharts 仅显示有关调整大小事件的数据

    html - 如何使用 CSS 使输入字段变大?

    jquery - 修复了比内容长的 div - 如何让内容粘在屏幕底部?

    javascript - 谷歌地图容器显示没有 map

    java - 如何在Android中绘制JButton

    android - 同一页面上的多个按钮 Activity - android eclipse

    javascript - 将变量传递到自定义按钮