In bootstrap, you can use the popover plug-in to realize the floating box on the right side. This plug-in is used to provide an extended view. You can set the display direction of the floating box by setting the "data-placement" attribute in the element. The syntax is: "
".
The operating environment of this tutorial: Windows 10 system, bootstrap version 3.3.7, DELL G3 computer
Bootstrap pop-up box (Popover) plug-in
The pop-up box (Popover) is similar to the tool tip (Tooltip), providing 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.
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 to an anchor/button tag -toggle="popover" will do. 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)
Popover plugin Unlike the drop-down menus and other plugins discussed previously, it is not a 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 following example demonstrates the use of the popover plug-in through the data attribute.
<!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-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>
Output result:
Related recommendations: bootstrap tutorial
The above is the detailed content of How to implement a floating box on the right side in bootstrap. For more information, please follow other related articles on the PHP Chinese website!