- Bulma 教程
- Bulma - 主页
- Bulma - 简介
- Bulma - 概述
- Bulma - 修饰符
- Bulma - 列
- Bulma - 布局
- Bulma - 表单
- Bulma - 元素
- Bulma - 组件
- Bulma 有用资源
- Bulma - 快速指南
- Bulma - 资源
- Bulma - 讨论
Bulma - 模态窗口
描述
模态窗口是在父窗口上分层的子窗口。它显示来自一个独立来源(不离开父窗口)的内容,并且可以执行交互操作。
你可以使用 modal 类以及以下 3 个模态窗口类在页面上显示该模态窗口 −
modal-background − 它显示透明的叠加效果。
modal-content − 它将模态窗口内容包含在水平和垂直居中的容器中。
modal-close − 它用于关闭模态窗口。
以下示例显示了如何使用上面的类在页面上显示模态窗口 −
<!DOCTYPE html> <html> <head> <meta charset = "utf-8"> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <title>Bulma Elements Example</title> <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css"> <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <section class = "section"> <div class = "container"> <span class = "title"> Simple Modal </span> <br> <br> <p> <a class = "button is-primary modal-button" data-target = "#modal">Launch example modal</a> </p> <div id = "modal" class = "modal"> <div class = "modal-background"></div> <div class = "modal-content"> <div class = "box"> <article class = "media"> <div class = "media-left"> <figure class = "image is-64x64"> <img src = "https://tutorialspoint.com/bootstrap/images/64.jpg" alt="Image"> </figure> </div> <div class = "media-content"> <div class = "content"> <p> <strong>Will Smith</strong> <small>@wsmith</small> <small>31m</small> <br> This is simple text. This is simple text. This is simple text. This is simple text. </p> </div> <nav class = "level"> <div class = "level-left"> <a class = "level-item"> <span class = "icon is-small"> <i class = "fa fa-reply"></i> </span> </a> <a class = "level-item"> <span class = "icon is-small"> <i class = "fa fa-retweet"></i> </span> </a> </div> </nav> </div> </article> </div> </div> <button class = "modal-close is-large" aria-label = "close"></button> </div> </div> </section> <script> $(".modal-button").click(function() { var target = $(this).data("target"); $("html").addClass("is-clipped"); $(target).addClass("is-active"); }); $(".modal-close").click(function() { $("html").removeClass("is-clipped"); $(this).parent().removeClass("is-active"); }); </script> </body> </html>
它显示以下输出 −
图像模态窗口
Bulma 允许你通过添加 image 类以及图像路径在模态窗口中显示图像,如下面的示例所示 −
<!DOCTYPE html> <html> <head> <meta charset = "utf-8"> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <title>Bulma Elements Example</title> <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css"> <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <section class = "section"> <div class = "container"> <span class = "title"> Image Modal </span> <br> <br> <p> <a class = "button is-primary modal-button" data-target = "#modal">Launch image modal</a> </p> <div id = "modal" class = "modal"> <div class = "modal-background"></div> <div class = "modal-content"> <p class = "image is-128x128"> <img src = "https://tutorialspoint.com/bootstrap/images/64.jpg" alt=""> </p> </div> <button class = "modal-close is-large" aria-label="close"></button> </div> </div> </section> <script> $(".modal-button").click(function() { var target = $(this).data("target"); $("html").addClass("is-clipped"); $(target).addClass("is-active"); }); $(".modal-close").click(function() { $("html").removeClass("is-clipped"); $(this).parent().removeClass("is-active"); }); </script> </body> </html>
它显示以下输出 −
模态窗口卡片
Bulma 使用模态窗口卡片以一种盒子形式显示内容,从而提升了外观效果。
让我们通过使用 modal-card 类创建一个模态窗口卡片的示例 −
<!DOCTYPE html> <html> <head> <meta charset = "utf-8"> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <title>Bulma Elements Example</title> <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css"> <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <section class = "section"> <div class = "container"> <span class = "title"> Modal Card </span> <br> <br> <p> <a class = "button is-primary modal-button" data-target = "#modal">Launch Card modal</a> </p> <div id = "modal" class = "modal"> <div class = "modal-background"></div> <div class = "modal-card"> <header class = "modal-card-head"> <p class = "modal-card-title">Modal Card</p> <button class = "delete" aria-label = "close"></button> </header> <section class = "modal-card-body"> <div class = "content"> <h1>Level One</h1> <p> This is simple text. This is simple text. This is simple text. This is simple text. </p> <h2>Level Two</h2> <p> This is simple text. This is simple text. This is simple text. This is simple text. </p> <h3>Level Three</h3> <blockquote> This is simple text. This is simple text. This is simple text. This is simple text. </blockquote> <h4>Level Four</h4> <p> This is simple text. This is simple text. This is simple text. This is simple text. </p> <h5>Level Five</h5> <p> This is simple text. This is simple text. This is simple text. This is simple text. </p> </ul> </div> </section> </div> </div> </div> </section> <script> $(".modal-button").click(function() { var target = $(this).data("target"); $("html").addClass("is-clipped"); $(target).addClass("is-active"); }); $(".modal-close").click(function() { $("html").removeClass("is-clipped"); $(this).parent().removeClass("is-active"); }); </script> </body> </html>
它显示以下输出 −
bulma_components.htm
广告