New! My 44-page ebook "CSS in 44 minutes" is out! 😃

Get it now →

Modal | 模态窗

一个经典的 模态 叠加层,您可以在其中包含 任何 您想要的内容。

Colors No
Sizes No
Variables Yes

模态窗的结构非常简单:

  • modal: 主容器
    • modal-background: 一个透明的覆盖层,可以点击来关闭模态窗
    • modal-content: 一个水平垂直居中的容器,最大宽度为 640px,在其中可以包含 任何 内容。
    • modal-close: 右上角的一个简单叉叉

Launch example modal

<div class="modal">
  <div class="modal-background"></div>
  <div class="modal-content">
    <!-- Any other Bulma elements you want -->
  </div>
  <button class="modal-close is-large" aria-label="close"></button>
</div>

激活 模态窗,只需要在 .modal 容器上添加 is-active 修饰符

No JavaScript
Bulma 没有 包含任何 JavaScript 交互,您将不得不自己实现 class 的交互。

包含图片的模态窗

因为模态窗可以包含 任何你想要的东西,你可以非常简单的使用它来创建一个图片集,例如:

Launch image modal

<div class="modal">
  <div class="modal-background"></div>
  <div class="modal-content">
    <p class="image is-4by3">
      <img src="https://img.higrid.net/images/placeholders/1280x960.png" alt="">
    </p>
  </div>
  <button class="modal-close is-large" aria-label="close"></button>
</div>

包含卡片的模态窗

如果您想要一个更经典的模态窗,包含 headbodyfoot, 可以使用modal-card

Launch modal card

<div class="modal">
  <div class="modal-background"></div>
  <div class="modal-card">
    <header class="modal-card-head">
      <p class="modal-card-title">Modal title</p>
      <button class="delete" aria-label="close"></button>
    </header>
    <section class="modal-card-body">
      <!-- Content ... -->
    </section>
    <footer class="modal-card-foot">
      <button class="button is-success">Save changes</button>
      <button class="button">Cancel</button>
    </footer>
  </div>
</div>

Variables | 变量 #

你可以使用 这些变量自定义 这些 component。只需要在导入 Bulma 之前设置这些变量 学习如何开始.

Name Default value
Name Default value
$modal-z 20
$modal-background-background-color rgba($black, 0.86)
$modal-content-width 640px
$modal-content-margin-mobile 20px
$modal-content-spacing-mobile 160px
$modal-content-spacing-tablet 40px
$modal-close-dimensions 40px
$modal-close-right 20px
$modal-close-top 20px
$modal-card-spacing 40px
$modal-card-head-background-color $background
$modal-card-head-border-bottom 1px solid $border
$modal-card-head-padding 20px
$modal-card-head-radius $radius-large
$modal-card-title-color $text-strong
$modal-card-title-line-height 1
$modal-card-title-size $size-4
$modal-card-foot-radius $radius-large
$modal-card-foot-border-top 1px solid $border
$modal-card-body-background-color $white
$modal-card-body-padding 20px

Made with Bulma
这是一个 开源项目. 错别字? Or 有疑问? 在GitHub上改进这个页面。

Bulma Partners

Check out their products!

Bulma Newsletter

Get notified when v1 is ready!