Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
420 views
in Technique[技术] by (71.8m points)

css - Bulma modal spacing on mobile

So when looking at the Bulma documentation (https://bulma.io/documentation/components/modal/), I am using the modals for both desktop and mobile but I'm having some formatting issues.

On Bulma, the mobile view doesn't add any spacing on the sides as below:
enter image description here

Does anyone know a native way to add spacing on modals for Bulma? I used px-4 which works great, but it adds the padding on desktop also, but I have the following modal structure:

<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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you don't mind overriding the linked Bulma CSS style sheet, you can do something like this:

<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/[email protected]/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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...