Skip to content
Related Articles

Related Articles

How to make Draggable and Scrollable Bootstrap modal on android device ?

View Discussion
Improve Article
Save Article
  • Last Updated : 18 Jan, 2021

Given an HTML document and the task is to create a bootstrap modal that can be scrolled and dragged on a mobile device. This task can be easily achieved using the “Scrolling long content” modals available in the Bootstrap library.

Approach: Modals are built with HTML, CSS, and JavaScript. They are positioned over everything else in the document, thus they remove scroll from the <body> element so that modal content scrolls instead. When modals become too long for the user’s viewport or device, they scroll independently of the page itself. So, in order to create a modal that is draggable and scrollable in mobile devices, no additional work has to be done except for exporting a default modal from the Bootstrap library and it will automatically become scrollable once we add some long content inside the modal body. Refer to the given example for further demonstration.



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width,initial-scale=1.0" />
    <!--Bootstrap CSS CDN-->
    <link rel="stylesheet" href=
        crossorigin="anonymous" />
    <!--Bootstrap javascript plugins-->
    <script src=
    <script src=
    <h2 class="m-5">Long Scrollable Modal</h2>
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-primary m-5" 
        Launch demo modal
    <!-- Modal -->
    <div class="modal fade" id="exampleModalLong" 
        tabindex="-1" role="dialog" 
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" 
                    <button type="button" class="close" 
                        <span aria-hidden="true">
                <div class="modal-body">
                    Bootstrap is a free and open-source
                    tool collection for creating responsive 
                    websites and web applications. It is the
                    most popular HTML, CSS, and JavaScript 
                    framework for developing responsive, 
                    mobile-first web sites. Nowadays, the 
                    websites are perfect for all the browsers
                    (IE, Firefox and Chrome) and for all sizes
                    of screens (Desktop, Tablets, Phablets, 
                    and Phones). All thanks to Bootstrap
                    developers – Mark Otto and Jacob Thornton
                    of Twitter, though it was later declared
                    to be an open-source project.
                <div class="modal-footer">
                    <button type="button" 
                        class="btn btn-secondary" 
                    <button type="button" 
                        class="btn btn-primary">
                        Save changes


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!