简体   繁体   English

无法在Bootstrap中实现模式

[英]Can't Implement the Modal in Bootstrap

i am newbie. 我是新手。 I am Creating a button on my homepage,once clicked it shows a modal showing the signin form and i am making a separate html page for my Modal. 我正在主页上创建一个按钮,单击该按钮会显示一个显示登录表单的模式,并且正在为我的模式制作一个单独的html页面。 Here is my Main Code where the Button is placed in my homepage. 这是我的主代码,按钮位于我的主页中。

<button id="btn1"><a href="signin.html" class="btn btn-success"data-toggle="modal"data-target="#mymodal"type="button">

<span class="glyphicon glyphicon-edit">
</span> Sign In</a>
</button> 

In signin.html 在signin.html中

<div class="modal"id="mymodal" >
    <h3 class="modal-header">

    <h1>
    We Are Glad you are Here!
        </h1>
    </div>
<div class="modal-body">
        <div class="container">

      <form class="form-signin">
        <h6 class="form-signin-heading">
   Please sign In</p>
        <label for="inputEmail" class="sr-only">Email address</label>
        <input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
        <div class="checkbox">
          <label>
            <input type="checkbox" value="remember-me"> Remember me
          </label>
        </div>
        <button class="btn btn-sm btn-primary" type="submit" data-toggle="modal">Sign in</button>
      </form>


    </div>
        <div class="modal-footer">
    <button class="btn" data-dismiss="modal"aria-hidden="true">Close</button>

</div>  </div>

Issue 问题

Modal ain't popping up on same page but it's going on next page.How should i fix it?so that my Signup form remains on the front page. 模式不会在同一页面上弹出,但会在下一页上显示。我该如何解决?我的注册表单仍保留在首页上。

Working Example 工作实例

I think the target element with the id mymodal should be in the same page with button , try to place <div class="modal"id="mymodal" ></div> after the button : 我认为id为mymodal的目标元素应该与button位于同一页面中,尝试将<div class="modal"id="mymodal" ></div>放在按钮之后:

<button id="btn1">
    <a href="signin.html" class="btn btn-success" data-toggle="modal" 
      data-target="#mymodal"type="button">
         <span class="glyphicon glyphicon-edit"></span> Sign In
    </a>
</button>
<div class="modal"id="mymodal" ></div> //place the target div after button

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM