无法将模态带到前面

时间:2019-07-11 06:48:26

标签: javascript html css modal-dialog bootstrap-modal

我有一个问题,莫代尔引导程序没有到达模态背景的前面。如代码片段中所示,当用户按下“部署”时,将弹出模式。在我的版本中,模式位于“后退”中,无法与“发送”和“取消”按钮进行交互。我仔细地看了看,这是因为我的项目中有一个“ min.css”文件。如何覆盖它,以便能够与模式中的按钮进行交互?我尝试了z-index,但是没有用。

var modal = document.getElementById("myModal");
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];

btn.onclick = function() {
  modal.style.display = "block";
}

span.onclick = function() {
  modal.style.display = "none";
}

window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}
.modal-content {

  background: linear-gradient(-45deg, #89f7fe 0%, #66a6ff 60%, #23A6D5, #23D5AB);
  margin:auto;
  padding: 20px;
  border: 1px solid #888;
  width: 500px;
  height: 500px;
  -webkit-animation-name: animatetop;
   -webkit-animation-duration: 0.4s;
   animation-name: animatetop;
   animation-duration: 0.4s

}

.modal{
  display: none;
  position:absolute;
  z-index: 10000;
  padding-top: 100px;
  left: 0px;
  top: 0px;
  width: 100%;
  max-height: 100%;
  background-color: rgb(0,0,0);
  background-color: rgba(0,0,0,0.4);

}

.modal2-content {
  background: white;
  margin:auto;
  width: 500px;
  -webkit-animation-name: animatetop;
   -webkit-animation-duration: 0.4s;
   animation-name: animatetop;
   animation-duration: 0.4s

}

.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0.5;
}
<!DOCTYPE html>
<html lang="en">

	<head>

		<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"/>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"/>
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />

		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"/>
		<!-- <link href="css/sb-admin-2.min.css" rel="stylesheet"> -->

		<link href="css/couponsexample.css" rel="stylesheet" />
	</head>

	<body id="page-top">
		<div id="wrapper">
			<div id="content-wrapper" class="d-flex flex-column">
				<div id="content">
					<div class="container-fluid">
						<div class="card shadow mb-4">
							<div class="card-header py-3">
								<span style="display:flex; justify-content:flex-end; width:100%; padding:0;">
									<button class="buttonTest" id="myBtn">New Discount</button>
								</span>
							</div>

							<div class="modal fade" id="largeModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
								<div class="modal-dialog modal-lg">
									<div class="modal2-content">
										<div style="background-color:#1E90FF" class="modal-header">
											<font color="white">
												<h4 class="modal-title" id="myModalLabel">Confirm Deployment</h4>
											</font>
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
												<span aria-hidden="true">&times;</span>
											</button>
										</div>
										<div class="modal-body">
											<p>Please confirm that the deployed coupon is accurate and ready. Once deployed, you cannot retake the coupon until it expires. Canceling will cause problems Test Test Tes</p>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
											<button type="button" class="btn btn-primary">Send</button>
										</div>
									</div>
								</div>
							</div>

							<div class="card-body">
								<div id="myModal" class="modal">
									<div class="modal-content" >
										<form id="msform">
											<span class="close">&times;</span>
											<fieldset>
												<h3 class="fs-subtitle">Step 4</h3>
											</fieldset>
										</form>
									</div>
								</div>
								<section>
									<div class="container">
										<div class="row">
											<div class="col s12 m6">
												<div class="card">
													<span>
														<a href="#" class="buttonDeploy" style="position: absolute; right: 12px; top:5px" data-toggle="modal" data-target="#largeModal">Deploy</a>
													</span>
													<div class="card-content">
														<span class="card-title blue-text text-darken-2"  style="white-space: nowrap">$5.00 Discount</span>
													</div>
												</div>
											</div>
										</div>
									</div>
								</section>
							</div>

						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"/>
		<script src="couponsjs.js"/>
	</body>
</html>

enter image description here

0 个答案:

没有答案