Articles → BOOTSTRAP → Create A Dropdown Menu Using The Btn-Group Class In Bootstrap

Create A Dropdown Menu Using The Btn-Group Class In Bootstrap






Code


<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
      <title></title>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class="btn-group">
         <button type="button" class="btn btn-primary">Menu1</button>
         <button type="button" class="btn btn-primary">Menu2</button>
         <div class="btn-group">
            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
            Menu3<span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
               <li><a href="#">Submenu1</a></li>
               <li><a href="#">Submenu2</a></li>
            </ul>
         </div>
      </div>
   </body>
</html>



Output


Picture showing the output of creating a dropdown menu using the btn-group class in Bootstrap
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, October 3, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250