如何创建另外两个弹出窗口

时间:2016-07-15 09:42:19

标签: jquery html

我想要一个弹出的忘记密码',它必须显示用户名&该窗口中的电子邮件文本框。我已经为登录创建了一个弹出窗口,是否可以在同一个div中创建忘记密码窗口?

HTML代码

<li><a id="modal-launcher" data-toggle="modal" data-target="#login-modal"><i class="fa fa-user"></i> Sign in</a></li>

HTML弹出代码

<div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header login_modal_header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h3 class="modal-title" id="myModalLabel">Login to Your Account</h3>
        </div>
        <div class="modal-body login-modal center-block">
            <p>By signing in, you agree to FOCUS 40's Terms and Conditions and Privacy Policy.</p>
            <br/>
            <div class="clearfix"></div>
            <div id='social-icons-conatainer'>
                <div class='modal-body-left'>
                    <div class="form-group">
                        <input type="text" id="username" placeholder="Enter your name" value="" class="form-control login-field">
                        <i class="fa fa-user login-field-icon"></i>
                    </div>

                    <div class="form-group">
                        <input type="password" id="login-pass" placeholder="Password" value="" class="form-control login-field">
                        <i class="fa fa-lock login-field-icon"></i>
                    </div>

                    <a href="#" class="btn btn-custom modal-login-btn center-block">Login</a>
                    <br/>
                    <a href="#" class="login-link center-block">Lost your password?</a>
                </div>
            </div>                                                                                                              
        </div> 

        <div class="modal-footer login_modal_footer">
        </div>
    </div>
</div>

CSS代码

.login_modal_footer{margin-top:5px;}
.login_modal_header .modal-title {text-align: center; }
.form-group{position: relative;}
.form-group .login-field-icon {font-size: 20px; position: absolute; right: 15px; top: 3px; transition: all 0.25s ease 0s; padding-top: 2%;}
.login_modal_header, .login_modal_footer {background: #F4F4F2 !important;color:#666;}
.login-modal input{height:40px; box-shadow: none; border:1px solid #ddd;}
.login-link{text-align:center; /*color:#ED6347;*/}
#center-line{position: absolute;  right: 265.7px;top: 80px;background:#ddd;  border: 4px solid #DDDDDD;border-radius: 20px;}
.modal-login-btn{width:50%;height:35px; margin-bottom:10px; text-align:center;}
#modal-launcher { cursor:pointer;}
#login-modal {margin-top:100px;}
.modal-body {padding:5% 10%;}

1 个答案:

答案 0 :(得分:1)

使用Jquery切换隐藏和显示div的一个登录和一个忘记密码HTML。以下是示例演示。

$(function(){
  
  $('#lostPass').on('click',function(){
    $('#signinWrapper').hide();
    $('#ForgotPassWrapper').show();
  });

  $('#backTologin').on('click',function(){
    $('#ForgotPassWrapper').hide();
    $('#signinWrapper').show();
  });
   
});
.login_modal_footer {
  margin-top: 5px;
}
.login_modal_header .modal-title {
  text-align: center;
}
.form-group {
  position: relative;
}
.form-group .login-field-icon {
  font-size: 20px;
  position: absolute;
  right: 15px;
  top: 3px;
  transition: all 0.25s ease 0s;
  padding-top: 2%;
}
.login_modal_header,
.login_modal_footer {
  background: #F4F4F2 !important;
  color: #666;
}
.login-modal input {
  height: 40px;
  box-shadow: none;
  border: 1px solid #ddd;
}
.login-link {
  text-align: center;
  /*color:#ED6347;*/
}
#center-line {
  position: absolute;
  right: 265.7px;
  top: 80px;
  background: #ddd;
  border: 4px solid #DDDDDD;
  border-radius: 20px;
}
.modal-login-btn {
  width: 50%;
  height: 35px;
  margin-bottom: 10px;
  text-align: center;
}
#modal-launcher {
  cursor: pointer;
}
#login-modal {
  margin-top: 100px;
}
.modal-body {
  padding: 5% 10%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

<li><a id="modal-launcher" data-toggle="modal" data-target="#login-modal"><i class="fa fa-user"></i> Sign in</a>
</li>

<div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header login_modal_header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3 class="modal-title" id="myModalLabel">Login to Your Account</h3>
      </div>
      <div class="modal-body login-modal center-block">
        <div id="signinWrapper">
          <p>By signing in, you agree to FOCUS 40's Terms and Conditions and Privacy Policy.</p>
          <br/>
          <div class="clearfix"></div>
          <div id='social-icons-conatainer'>
            <div class='modal-body-left'>
              <div class="form-group">
                <input type="text" id="username" placeholder="Enter your name" value="" class="form-control login-field">
                <i class="fa fa-user login-field-icon"></i>
              </div>

              <div class="form-group">
                <input type="password" id="login-pass" placeholder="Password" value="" class="form-control login-field">
                <i class="fa fa-lock login-field-icon"></i>
              </div>

              <a href="#" class="btn btn-custom modal-login-btn center-block">Login</a>
              <br/>
              <a id="lostPass" href="#" class="login-link center-block">Lost your password?</a>
            </div>
          </div>
        </div>
        <div id="ForgotPassWrapper" style="display:none;">
          <div class="form-group">
            <input type="text" placeholder="Enter your User name" value="" class="form-control login-field">
            <button id="sendLink" class="btn btn-primary">Send reset link</button>
              <button id="backTologin" class="btn btn-default">back to login</button>
          </div>
        </div>
      </div>

      <div class="modal-footer login_modal_footer">
      </div>
    </div>
  </div>

注意:以全屏模式查看演示