7.26. Bootstrap5 pop-up box

发布时间 : 2025-10-25 13:35:27 UTC      

Page Views: 10 views

The pop-up box control is similar to the prompt box, it is displayed after the mouse is clicked on the element, unlike the prompt box, it can display more content.

7.26.1. How to create a popup box

By adding to elements data-bs-toggle="popover" to create a pop-up box.

title the content of the property is the title of the pop-up box, and the data-bs- content property displays the text content of the pop-up box:

<button type="button" class="btn btn-primary" data-bs-toggle="popover" title="Popup Title" data-bs-content="Popup Box Content">Click me multiple timesbutton>    

Note: the pop-up box should be written in the initialization code of JavaScript.

The following examples can use pop-up boxes anywhere in the document:

Example

var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]')) var popoverList = popoverTriggerList.map(function (popoverTriggerEl) { return new bootstrap.Popover(popoverTriggerEl) }) 

7.26.2. Specify the location of the pop-up box

By default, the pop-up box is displayed on the right side of the element.

You can use the ‘data bs placement’ attribute to set the direction of the pop-up box display: top , bottom , left or right :

Example

<a href="#" title="title" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="I am the content section">Click mea> <a href="#" title="title" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="I am the content section">Click mea> <a href="#" title="title" data-bs-toggle="popover" data-bs-placement="left" data-bs-content="I am the content section">Click mea> <a href="#" title="title" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="I am the content section">Click mea>      

7.26.3. Close the pop-up box

By default, the pop-up box closes after clicking on the specified element again, and you can use the data-bs-trigger="focus" property to close the pop-up box by setting the area outside the mouse click element:

Example

<a href="#" title="Cancel Popup" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-content="Click elsewhere in the document to close me">Click mea>    

Tip: if you want to display and remove the mouse over the element, you can use the data-bs-trigger property and set the value to “hover”

Example

<a href="#" title="title" data-bs-toggle="popover" data-bs-trigger="hover" data-bs-content="some content">Move the mouse over to mea>       
                
                
            
        
        
《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。