bootstrap中的模型无法正常工作

时间:2013-08-01 07:38:35

标签: twitter-bootstrap

下面是bootstrap模型的代码,但它不能正常工作

<!DOCTYPE html>
<html>
<head>
<meta  charset="utf-8">
<meta name="viewport" content="width=device-width , initial-scale=1.0">
<title>bootstrap</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css">

</head>
<body>
                    <a href="#mymodel" class="btn" data-toggle="model">login</a>
        <div class="model hide" id="mymodel" aria-hidden="true" >
    <div class="model-header">
    <h1>Login</h1>
    </div>

    <div class="model-body">
    <form >
    <label>Email</label><input type="email" class="span3"></br>
    <label>Password</label><input type="password" class="span3"></br>
    <button type="submit" class="btn btn-success">Login</button>
    <button type="reset" class="btn ">Clear</button>
    </form>
    </div>
    <div class="model-footer">
   <button class="close" data-dismiss="model" aria-hidden="true">close</button>
    </div>

</div>
      <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
      <script src="js/bootstrap.js"></script>

      </body>
</html>

请帮我在bootstrap中创建一个模型我没事,但是当点击登录按钮时它没有出现在我的模型

2 个答案:

答案 0 :(得分:4)

它是“模态”,而不是“模型”。使用“ a ”。

所以你应该有data-toggle="modal"data-dismiss="modal"

答案 1 :(得分:1)

首先添加bootstrap css

<link rel="stylesheet" href="bootstrap.css" />

添加模型

<div class="modal hide fade" id="mymodel">
  <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h1>Login</h1>
  </div>
  <div class="modal-body">
    <form >
        <label>Email</label><input type="email" class="span3"></br>
        <label>Password</label><input type="password" class="span3"></br>
        <button type="submit" class="btn btn-success">Login</button>
        <button type="reset" class="btn ">Clear</button>
    </form>
  </div>
  <div class="modal-footer">
   <a class="btn" data-dismiss="modal" aria-hidden="true">close</a>
  </div>     
</div>

现在在所需位置添加<a href

<a class="btn" data-toggle="modal" href="#mymodel">login</a>

现在添加必需的脚本

<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="js/bootstrap.js"></script>

更新:jsfiddle demo

http://jsfiddle.net/suhailvs/w5jRa/