css 布尔玛模态间距在移动的

ie3xauqp  于 2023-05-08  发布在  其他
关注(0)|答案(2)|浏览(123)

因此,当查看Bulma文档(https://bulma.io/documentation/components/modal/)时,我使用了桌面和移动的的模态,但我遇到了一些格式问题。
在Bulma上,移动的视图不会在两侧添加任何间距,如下所示:

有没有人知道一个本地的方式来添加间距的模态布尔玛?我使用了px-4,效果很好,但它也在桌面上添加了填充,但我有以下模态结构:

<div id="mobile-profile-modal" class="modal">
    <div class="modal-background"></div>
    <div class="modal-card px-4">
        <header class="modal-card-head">
            <p class="modal-card-title"><?= $user->get_first_name(); ?></p>
            <button class="delete" aria-label="close"></button>
        </header>
        <section class="modal-card-body">
            <div class="container">
                <div class="columns is-centered">
                    <div class="column">
                        <button class="button is-fullwidth">Profile</button>
                        <button class="button is-fullwidth">Settings</button>
                    </div>
                </div>
            </div>
        </section>
        <footer class="modal-card-foot">
            <button class="button is-fullwidth is-primary">
                        <span class="icon">
                          <i class="fas fa-sign-out-alt"></i>
                        </span>
                <span>Logout</span>
            </button>
        </footer>
    </div>
</div>
6ie5vjzr

6ie5vjzr1#

如果你不介意覆盖链接的Bulma CSS样式表,你可以这样做:

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bulma Modal Example</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css">
<style type=text/css>
    .modal-card,
    .modal-content {
        margin: 0 20px;
        max-height: calc(100vh - 160px);
        overflow: auto;
        position: relative;
        /*remove width: 100%;*/
        width: calc(100% - 2em);
    }
    /*modal breakpoint*/
    @media screen and (min-width:769px) {
        .modal-card,
        .modal-content {
            margin: 0 auto;
            max-height: calc(100vh - 40px);
            width: 640px
        }
    }
</style>
6ss1mwsb

6ss1mwsb2#

除了@jurgenizer的优秀答案之外,SASS覆盖将类似于:

.modal-content, .modal-card {
  width: calc(100% - 4em);

  @media screen and (min-width:769px) {
    width: 640px;
  }
}

相关问题