VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/how-to-position-a-bootstrap-popover/

⇱ How to position a Bootstrap popover ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to position a Bootstrap popover ?

Last Updated : 22 Jun, 2020

This article describes how a popover can be positioned on the page. The popover attribute of Bootstrap can be used to make the website look more dynamic. Popovers are generally used to display additional information about any element and are displayed on click of mouse pointer over that element. It is similar to the Bootstrap Tooltip. However, a popover can contain much more content than a tooltip.

Popovers is the third-party library Popper.js for positioning the element. The library popper.min.js must be included before bootstrap.js

Syntax:

$(function () {
 $('[data-toggle="popover"]').popover()
})

Positioning can be sometimes very important as per need but the user needs to do it explicitly as Popover by default will appear on the right side of the element. 

Example 1: The below code is a basic implementation in HTML, Bootstrap, and JavaScript. All 4 directions (left, right, up and down) popover has been implemented using the data-placement settings. 

Output:
 

👁 Image


Example 2: The below example is a top hover popover where the popover triggers up when the cursor points to the button and disappears when the cursor is removed from the button.

Output:
 

👁 Image
Comment
Article Tags:

Explore