Bootstrap开关问题

Pau*_*oso 1 button css3 twitter-bootstrap twitter-bootstrap-3

我正在尝试使用自举开关,我遇到了一些问题.我在这里使用这个例子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>
Run Code Online (Sandbox Code Playgroud)

van*_*ren 7

你的依赖是不正常的; 他们应该是这样的.

<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"/>
Run Code Online (Sandbox Code Playgroud)

身体结束

<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>
Run Code Online (Sandbox Code Playgroud)

CSS订单

  1. Bootstrap CSS
  2. Boostrap Switch CSS
  3. 自定义CSS

JS订单

  1. jQuery的
  2. Bootstrap JS
  3. Bootstrap Switch JS

您还在页面上加载了两次jQuery(一次在头脑中,一次在主体末尾)在所有JS依赖项之前使用它一次.

$("[name='my-checkbox']").bootstrapSwitch();还需要放在一切为了其他JS的依赖之后它加载.

**旁注:您也缺少一个开头form标记.

$("[name='my-checkbox']").bootstrapSwitch();
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)