How to design Bootstrap Fullscreen Select feature for Mobiles ? - GeeksforGeeks

15 Oct, 2020
In this article, we will learn how to design Bootstrap fullscreen select feature for mobile devices.
The Bootstrap fullscreen select plugin key features are as follows.
It provides advanced HTML full screen select functionality.
It provides in and out animations.
It provides open and close events function callbacks.
It provides CSS3 animated buttons, dropdowns and texts.
Please download the required pre-compiled libraries from the link and keep it in the relevant working folder to implement the following examples. Developers should take care of proper file paths while coding and running.
Example 1: The following code is the basic example of the Bootstrap Fullscreen Select plugin. We will be setting attributes or properties into this basic code in further examples following this.
<!doctype html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible"             content="chrome=1">      <meta name="viewport" content=        "width=device-width,initial-scale=1,         user-scalable=no">      <script src="demo/libs/jquery.min.js">    </script>    <script src="demo/libs/bootstrap.min.js">    </script>      <link rel="stylesheet" href=        "demo/libs/bootstrap.min.css">      <link rel="stylesheet" href=        "demo/libs/bootstrap-theme.min.css">      <link rel="stylesheet"         href="demo/demo.min.css">      <link rel="stylesheet" type="text/css"     href="css/bootstrap-fullscreen-select.css"/>      <script type="text/javascript"         src="js/bootstrap-fullscreen-select.js">    </script>      <style type="text/css">        body {            font-family: Arial, sans-serif;            padding: 20px;            margin: 0 auto;          }    </style>  </head>  <body><br />    <b>Bootstrap Fullscreen Select Feature</b>    <p></p>      <div id="containerID">        <select class="form-control mobileSelect">            <option value="samsung">Samsung</option>            <option value="sony">Sony</option>            <option value="oneplus">OnePlus</option>            <option value="nokia">Nokia</option>        </select>      </div>    <script type="text/javascript">        $(function () {            $('.mobileSelect').mobileSelect();        });    </script>      <script type="text/javascript"         src="demo/demo.min.js">    </script></body>  </html>
Output:
Before Select:
After Select:
Note: The above basic HTML code structure is used for further examples. The code snippets are as follows.
Example 2: In the following example code, we will be adding Bootstrap multiple select feature and will disable the second dropdown group. In the JavaScript part of the code, we will be learning to add animation and padding options. Various other options are also available, the developer can try out according to his need.
<div id="containerID">    <select class="form-control mobileSelect"             data-style="primary" multiple>        <optgroup label="first group">            <option value="samsung">Samsung</option>            <option value="sony">Sony</option>            <option value="oneplus">OnePlus</option>        </optgroup>          <!-- Making the second group as disabled-->        <optgroup label="Second group"                 data-style="danger" disabled>            <option value="nokia">Nokia</option>            <option value="apple">Apple</option>        </optgroup>    </select></div><script type="text/javascript">    $(function () {        $('.mobileSelect').mobileSelect({            title: 'For all selected phones',                          // For animate effect of screen            animation: 'zoom',              padding: {                top: '50px',                left: '50px',                right: '50px',                bottom: '50px'            }        }        );    });</script>
Output:
Example 3: The following code demonstrates the “click”, “onOpen” and “onClose” event trigger for the plugin. The onOpen gets fired when the open animation starts and onClose gets fired after the close animation is performed.
<!doctype html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible"             content="chrome=1">      <meta name="viewport" content=        "width=device-width,         initial-scale=1, user-scalable=no">      <script src="demo/libs/jquery.min.js">    </script>    <script src="demo/libs/bootstrap.min.js">    </script>      <link rel="stylesheet" href=        "demo/libs/bootstrap.min.css">      <link rel="stylesheet" href=        "demo/libs/bootstrap-theme.min.css">      <link rel="stylesheet"         href="demo/demo.min.css">      <link rel="stylesheet" type="text/css"     href="css/bootstrap-fullscreen-select.css" />      <script type="text/javascript"         src="js/bootstrap-fullscreen-select.js">    </script>      <style type="text/css">        body {            font-family: Arial, sans-serif;            padding: 20px;            margin: 0 auto;          }          #containerID {            width: 300px;        }          #clickDivID {            width: 300px;            height: 100px;            color: white;            background-color: green;        }    </style></head>  <body>    <b>        Fullscreen Select Feature         with event triggers    </b>          <div id="containerID">        <select class="form-control mobileSelect"             data-triggerOn="#clickDivID">            <option value="samsung">Samsung</option>            <option value="sony">Sony</option>            <option value="oneplus">OnePlus</option>            <option value="nokia">Nokia</option>        </select>                  <div id="clickDivID">            <b>On click of this div, the                 dropdown is activated.            </b>        </div>      </div>    <script type="text/javascript">        $(function () {            $('.mobileSelect').mobileSelect({                title: 'Select any option',                buttonClear: 'Clear',                onClose: function () {                    alert('On Close event: '                             + $(this).val());                },                onOpen: function () {                    alert('On Open event: '                             + this.val());                }            });        });    </script>      <script type="text/javascript"         src="demo/demo.min.js">    </script></body>  </html>
The following message box is popped-up when the “open” event is triggered for the Bootstrap fullscreen select plugin.
The following message box is popped-up when the “open” event is triggered for the Bootstrap fullscreen select plugin.
When the user selects one option after the “click” event is triggered for the HTML “div”, the following output is shown.
When the user selects one option after the “click” event is triggered for the HTML “div”, the following output is shown.
The following message box is popped-up when the “close” event is triggered for the plugin.
The following message box is popped-up when the “close” event is triggered for the plugin.
Bootstrap-Misc
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to change navigation bar color in Bootstrap ?
Form validation using jQuery
How to align navbar items to the right in Bootstrap 4 ?
How to pass data into a bootstrap modal?
How to Show Images on Click using HTML ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?