一个页面上有多个模态弹出窗口

时间:2017-06-16 13:30:52

标签: javascript html5 css3

我一直在努力通过点击不同的按钮在一个页面上拥有多个模态。请帮助我,我是新来的。虽然我在测试域上有它,但您可能想要查看http://test.crewresolution.com/index.html

谢谢



// Get the modal
var modal = document.getElementById('myModal');

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal 
btn.onclick = function() {
    modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
&#13;
/* Modal Content */
.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border: 1px solid #888;
    width: 80%;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
    -webkit-animation-name: animatetop;
    -webkit-animation-duration: 0.4s;
    animation-name: animatetop;
    animation-duration: 0.4s;
    z-index: 10000;
}

/* Add Animation */
@-webkit-keyframes animatetop {
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1}
}

@keyframes animatetop {
    from {top:-300px; opacity:0}
    to {top:0; opacity:1}
}

/* The Close Button */
.close {
    color: white;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    padding: 2px 16px;
    background-color: #266eb8;
    color: white;
}

.modal-body {padding: 2px 16px;}

.modal-footer {
    padding: 2px 16px;
    background-color: #266eb8;
    color: white;
}
&#13;
<div class="row">
              <div class="col-md-4 wow fadeInUp">
                <div class="box-service">
                  <div class="ic-service text-center">
                    <i class="ti-cloud-up"></i>
                  </div>
                  <h4 class="text-uppercase color-dark title-service text-center">Message from Crew Resolution</h4>
                  <p>Resolution is a reformed group, which consist of 200 admins  as one of the best programmers from: Russia, India, South Africa and USA which form a single team. </p>
                                    <button id="myBtn">Click to see more >></button>
                  <!-- The Modal -->
<div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <div class="modal-header">
      <span class="close">&times;</span>
      <h4>Additional Benefits</h4>
    </div>
    <div class="modal-body">
      <p>1.	Free ticket worth N600k to South Africa for all active members with 100 direct down lines and have PH minimum amount of N500k or $1500 for 4 months.<br>
2.	 Free N150k will be given to  active members who have participated for 6 months after registration, and the money is for:<br>
•	Skills acquisition program.<br>
•	Business as an entrepreneur.<br>
•	School fee regarded as scholarship.<br>
No condition on amount PH in No.2<br>
3.	An active member within the first 4 months of registration with minimum PH of N500k or $1500 in bit coins in each month is qualified to get a loan of N2M and will be paid back for the next 6 months.<br>
Condition:  All of these will be in batches such as: batch A, B, C, D, E, F etc.  
</p>
    </div>
    <div class="modal-footer">
      <h4>Additional Benefits</h4>
    </div>
  </div>

</div>  
                </div>
              </div>
              <div class="col-md-4 wow fadeInUp" data-wow-delay="0.5s">
                <div class="box-service">
                  <div class="ic-service text-center">
                    <i class="ti-bar-chart"></i>
                  </div>
                  <h3 class="text-uppercase color-dark title-service text-center">Summary</h3>
                  <p>➢	40% in local currency (Naira) per month.<br> 
➢	60% in bit coin per month. <br>
➢	10% constant referral bonus from all direct down lines.<br>
</p>
                  <button id="myBtn">Click to see more >></button>
                  <!-- The Modal -->
<div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <div class="modal-header">
      <span class="close">&times;</span>
      <h4>Summary</h4>
    </div>
    <div class="modal-body">
      <p>➢	40% in local currency (Naira) per month.<br>
➢	60% in bit coin per month. <br>
➢	10% constant referral bonus from all direct down lines.<br>
➢	“Alert FBI Icon” conditions: Raise “Alert FBI” only when there is fake POP. Abuse of this will lead to account blocking permanently.<br>
➢	First time registration bonus once:<br>
N10k	-	N99k gives bonus of N6k or $20<br>
N100k	-	N499k gives bonus of N20k or $50<br>
N500k	-	N1M	 gives bonus of N50k or $150<br>
➢	Minimum PH of N10k<br>
➢	Once PH there is an instant matching to pay 10% of your total amount PH as a commitment.<br> The remaining 90% will be matched at least 20 days later.

</p>
    </div>
    <div class="modal-footer">
      <h4>Summary</h4>
    </div>
  </div>

</div>
                </div>
              </div>
              <div class="col-md-4 wow fadeInUp" data-wow-delay="1s">
                <div class="box-service">
                  <div class="ic-service text-center">
                    <i class="ti-mobile"></i>
                  </div>
                  <h4 class="text-uppercase color-dark title-service text-center">Additional Benefits</h4>
                  <p>1.	Free ticket worth N600k to South Africa for all active members with 100 direct down lines and have PH minimum amount of N500k or $1500 for 4 months.</p>
                  <button id="myBtn">Click to see more >></button>
                  <!-- The Modal -->
<div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <div class="modal-header">
      <span class="close">&times;</span>
      <h4>Additional Benefits</h4>
    </div>
    <div class="modal-body">
      <p>1.	Free ticket worth N600k to South Africa for all active members with 100 direct down lines and have PH minimum amount of N500k or $1500 for 4 months.<br>
2.	 Free N150k will be given to  active members who have participated for 6 months after registration, and the money is for:<br>
•	Skills acquisition program.<br>
•	Business as an entrepreneur.<br>
•	School fee regarded as scholarship.<br>
No condition on amount PH in No.2<br>
3.	An active member within the first 4 months of registration with minimum PH of N500k or $1500 in bit coins in each month is qualified to get a loan of N2M and will be paid back for the next 6 months.<br>
Condition:  All of these will be in batches such as: batch A, B, C, D, E, F etc.  
</p>
    </div>
    <div class="modal-footer">
      <h4>Additional Benefits</h4>
    </div>
  </div>

</div>
                </div>
              </div>
            </div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您需要为模式提供不同的ID,ID必须是唯一的且仅适用于1个元素。 你可以拥有myModal1,myModal2,myModalx。