Home  >  Article  >  Web Front-end  >  Is there a popup layer in bootstrap?

Is there a popup layer in bootstrap?

WBOY
WBOYOriginal
2022-06-16 15:57:001875browse

There is a pop-up layer in bootstrap; you can use the Popover plug-in to implement the pop-up layer. The plug-in can generate specified content and tags according to requirements, place the generated content in the pop-up box triggered by the specified element, and enable the pop-up box. The syntax is "element object.popover(options)".

Is there a popup layer in bootstrap?

The operating environment of this tutorial: Windows 10 system, bootstrap version 5, DELL G3 computer

Is there a pop-up layer in bootstrap

Popovers are similar to tooltips and provide an expanded view. To activate the popover, users simply hover over the element. The content of the popup box can be filled entirely using the Bootstrap Data API. This method relies on tooltips.

If you want to reference the functionality of this plugin separately, then you need to reference popover.js, which depends on the Tooltip plugin. Alternatively, as mentioned in the Bootstrap Plugin Overview chapter, you can reference bootstrap.js or a minified version of bootstrap.min.js.

Usage

The popover plug-in generates content and markup according to requirements. By default, popovers are placed behind their triggering elements. You can add a popover in two ways:

Through the data attribute: To add a popover, just add data-toggle="popover" to an anchor/button tag That’s it. The title of the anchor is the text of the popover. By default, the plugin places the popover at the top.

<a href="#" data-toggle="popover" title="Example popover">
    请悬停在我的上面
</a>

Via JavaScript: Enable popover via JavaScript:

$(&#39;#identifier&#39;).popover(options)

The popover plug-in is not a pure CSS plug-in like the drop-down menus and other plug-ins discussed previously. . To use the plugin, you must activate it using jquery (read javascript). Use the following script to enable all popovers on the page:

$(function () { $("[data-toggle=&#39;popover&#39;]").popover(); });

Example is as follows:

<body>
<div class="container" style="padding: 100px 50px 10px;" >
<button type="button" class="btn btn-default" title="Popover title"  
data-container="body" data-toggle="popover" data-placement="left" 
data-content="左侧的 Popover 中的一些内容">
左侧的 Popover
</button>
<button type="button" class="btn btn-primary" title="Popover title"  
data-container="body" data-toggle="popover" data-placement="top" 
data-content="顶部的 Popover 中的一些内容">
顶部的 Popover
</button>
<button type="button" class="btn btn-success" title="Popover title"  
data-container="body" data-toggle="popover" data-placement="bottom" 
data-content="底部的 Popover 中的一些内容">
底部的 Popover
</button>
<button type="button" class="btn btn-warning" title="Popover title"  
data-container="body" data-toggle="popover" data-placement="right" 
data-content="右侧的 Popover 中的一些内容">
右侧的 Popover
</button>
</div>
<script>
$(function () { 
$("[data-toggle=&#39;popover&#39;]").popover();
});
</script>
</body>
</html>

Output result:

Is there a popup layer in bootstrap?

Related recommendations: bootstrap tutorial

The above is the detailed content of Is there a popup layer in bootstrap?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn