Ich habe ein Modal und innerhalb dieses Modals gibt es eine Dropdown-Liste, die große versteckte Inhalte anzeigt, die funktionieren.
Wenn Sie jetzt das nächste Modal öffnen, das über dem ersten Modal gestapelt ist, und es schließen, wird das Scrollen auf dem darunter liegenden Modal deaktiviert.
Ich habe ein vollständiges Beispiel erstellt, einschließlich der Schritte zum Replizieren des Problems, mit dem ich konfrontiert bin. Du kannst es sehen hier.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<title></title>
<style>
</style>
</head>
<body>
<input type="button" data-toggle="modal" data-target="#modal_1" class="btn btn-lg btn-primary" value="Open Modal 1" >
<div class="modal fade" id="modal_1">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">First Modal</h4>
</div>
<div class="modal-body">
<form class="form">
<div class="form-group">
<label>1) Open This First: </label>
<input type="button" data-toggle="modal" data-target="#modal_2" class="btn btn-primary" value="Open Modal 2" >
</div>
<div class="form-group">
<label>2) Change this once you have opened the modal above.</label>
<select id="change" class="form-control">
<option value="small">Show Small Content</option>
<option value="large">Show Large Content</option>
</select>
</div>
<div id="large" class="content-div">
<label>Large Textarea Content.. Try and scroll to the bottom..</label>
<textarea rows="30" class="form-control"></textarea>
</div>
<div id="small" class="content-div">
<label> Example Text Box</label>
<input type="text" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal_2">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Second Modal</h4>
</div>
<div class="modal-body">
<hp>This is the stacked modal.. Close this modal, then chenge the dropdown menu, you cannot scroll... </h5>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$(".content-div").hide();
$("#change").change(function() {
$(".content-div").hide();
$("#" + $(this).val()).show();
});
});
</script>
</html>
Hier ist ein Bootply, um das Verhalten in Aktion zu zeigen:
„Achten Sie darauf, kein Modal zu öffnen, während ein anderes noch sichtbar ist. Um mehr als ein Modal gleichzeitig anzuzeigen, ist benutzerdefinierter Code erforderlich.“und verstößt auch gegen den Zweck, für den Modale bestimmt waren.
– Brandstifter
21. Januar 2015 um 22:04 Uhr
Siehe auch stackoverflow.com/a/24914782/58241, das nicht nur eine Lösung für das Scrollbar-Problem, sondern auch für Styling-Probleme enthält
– benrwb
12. November 2020 um 18:17 Uhr