Home  >  Article  >  Web Front-end  >  Why does the bootstrap pop-up box have no content?

Why does the bootstrap pop-up box have no content?

(*-*)浩
(*-*)浩Original
2019-07-19 10:07:251954browse

Popover is similar to Tooltip and provides 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.

Why does the bootstrap pop-up box have no content?

Popover plug-ins generate content and markup according to requirements. By default, popovers are placed on their triggering elements. later. You can add a popover in the following two ways: (Recommended learning: Bootstrap video tutorial)

Through the data attribute: If you need to add a popover (popover), just add data-toggle="popover" to an anchor/button tag. 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:

$('#identifier').popover(options)

The Popover plugin is not like the drop-down menus and other plugins discussed previously. Pure CSS plugin. 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='popover']").popover(); });

The example below demonstrates how to pass data The property uses the usage of the popover plug-in.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"> 
    <title>Bootstrap 实例 - 弹出框(Popover)插件</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<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='popover']").popover();
});
</script>

</body>
</html>

For more technical articles related to Bootstrap, please visit the Bootstrap Tutorial column to learn!

The above is the detailed content of Why does the bootstrap pop-up box have no content?. 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