I am trying to implement a full-screen modal using Bootstrap 4 that incorporates a scrollspy feature for scrolling the content within the modal body. I have successfully achieved the full-screen aspect, but I am facing issues with making the content scroll within the modal. How can I solve this problem?
Update: Additionally, the scrollspy functionality seems to be not working. Any suggestions on how to fix this?
<head>
<!-- Include Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Include Bootstrap JS and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<!-- Button to open the modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open Modal
</button>
<div class="modal" id="myModal">
<div class="modal-dialog modal-xl" style="max-width: 100%; margin: 5px;">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modal with Scrollspy</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body d-flex">
<div data-spy="scroll" data-target="#scrollspy" data-offset="0">
<div id="section1">
<h3>Section 1</h3>
<p>Content for Section 1 goes here.</p>
</div>
<div id="section2">
<h3>Section 2</h3>
<p>Content for Section 2 goes here.</p>
</div>
<div id="section3">
<h3>Section 3</h3>
<p>Content for Section 3 goes here.</p>
</div>
</div>
<div id="scrollspy" class="list-group">
<a class="list-group-item list-group-item-action" href="#list-item-1">Item 1</a>
<a class="list-group-item list-group-item-action" href="#list-item-2">Item 2</a>
<a class="list-group-item list-group-item-action" href="#list-item-3">Item 3</a>
<a class="list-group-item list-group-item-action" href="#list-item-4">Item 4</a>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>