How to change the width and height of Twitter Bootstrap's tooltips? - GeeksforGeeks

31 Jan, 2020
Bootstrap tooltip: A Tooltip is used to provide interactive textual hints to the user about the element when the mouse pointer moves over. Standardized bootstrap element collection like a small pop-up which appears whenever user performs any specific action click, hover(default), and focus on that element. It also supports manual trigger for specific events.
In this article, we will design the tooltip first then we will manipulate the height and width of that tooltip.Create tooltip: The data-toggle=”tooltip” attribute is used to create a tooltip. The title attribute is used to specify the text that should be displayed inside the tooltip.
Program:<!DOCTYPE html> <html lang="en"> <head>     <title>Tooltip</title>           <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">       <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">           <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>           <script src= "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">     </script>           <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">     </script> </head>   <body style="text-align:center;">           <div class="container">                   <h1 style="color:green;" data-toggle="tooltip" title="Tooltip">             GeeksforGeeks         </h1>     </div>           <script>         $(document).ready(function() {             $('[data-toggle="tooltip"]').tooltip();         });     </script> </body>   </html>                     
<!DOCTYPE html> <html lang="en"> <head>     <title>Tooltip</title>           <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">       <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">           <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>           <script src= "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">     </script>           <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">     </script> </head>   <body style="text-align:center;">           <div class="container">                   <h1 style="color:green;" data-toggle="tooltip" title="Tooltip">             GeeksforGeeks         </h1>     </div>           <script>         $(document).ready(function() {             $('[data-toggle="tooltip"]').tooltip();         });     </script> </body>   </html>                     
Output:
Changing width/height of tooltip: Here, we will modify the .tooltip-inner class for satisfying that demand by over-riding the some of the default CSS properties. Below is the implementation for the same.
Program:<!DOCTYPE html> <html lang="en"> <head>     <title>Tooltip</title>           <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">       <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">           <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>           <script src= "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">     </script>           <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">     </script>     <style>        body {            text-align:center;        }                  h1 {            color: green;        }        .tooltip-inner                    {                        width:200px;                        height:100px;                         padding:4px;                    }    </style></head>   <body>           <div class="container">                   <h1 data-toggle="tooltip"             title="A Computer Science Portal for Geeks">             GeeksforGeeks         </h1>     </div>           <script>         $(document).ready(function() {             $('[data-toggle="tooltip"]').tooltip();         });     </script> </body>   </html>                        
<!DOCTYPE html> <html lang="en"> <head>     <title>Tooltip</title>           <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">       <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">           <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>           <script src= "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">     </script>           <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">     </script>     <style>        body {            text-align:center;        }                  h1 {            color: green;        }        .tooltip-inner                    {                        width:200px;                        height:100px;                         padding:4px;                    }    </style></head>   <body>           <div class="container">                   <h1 data-toggle="tooltip"             title="A Computer Science Portal for Geeks">             GeeksforGeeks         </h1>     </div>           <script>         $(document).ready(function() {             $('[data-toggle="tooltip"]').tooltip();         });     </script> </body>   </html>                        
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
Bootstrap-Misc
CSS-Misc
HTML-Misc
Picked
Technical Scripter 2019
Bootstrap
HTML
Technical Scripter
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Show Images on Click using HTML ?
How to set Bootstrap Timepicker using datetimepicker library ?
How to change the background color of the active nav-item?
How to Use Bootstrap with React?
Difference between Bootstrap 4 and Bootstrap 5
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property