html - Bulma.io 全高英雄背景

标签 html css frameworks frontend bulma

尝试将背景图片添加到 bulma.io 英雄部分,但它不起作用!

代码如下:

<div>
    <section class="hero is-primary is-fullheight header-image">
        <!-- Hero header: will stick at the top -->
        <div class="hero-head">
            <header class="navbar">
                <div class="navbar-brand">
                    <a class="navbar-item" href="http://bulma.io">
                        <img src="http://bulma.io/images/bulma-logo.png" alt="Bulma: a modern CSS framework based on Flexbox" width="112" height="28">
                    </a>

                    <div class="navbar-burger" v-on:click="showNav = !showNav" v-bind:class="{ 'is-active' : showNav }">
                        <span></span>
                        <span></span>
                        <span></span>
                    </div>
                </div>
                <div class="navbar-menu" v-bind:class="{ 'is-active' : showNav }">
                    <!-- navbar start, navbar end -->
                    <div class="navbar-end">
                        <a class="navbar-item" href="/about">About</a>
                        <a class="navbar-item" href="/path">Path</a>
                        <a class="navbar-item" href="/blog">Blog</a>
                    </div>
                </div>
            </header>
        </div>


        <!-- Hero content: will be in the middle -->
        <div class="hero-body">
            <div class="container has-text-centered">
                <h1 class="title">
                    Title
                </h1>
                <h2 class="subtitle">
                    Subtitle
                </h2>
            </div>
        </div>
        <!-- Hero footer: will stick at the bottom -->
        <div class="hero-foot">
            <nav class="tabs is-boxed is-fullwidth">
                <div class="container">
                    <ul>
                        <li class="is-active"><a>Overview</a></li>
                        <li><a>Modifiers</a></li>
                        <li><a>Grid</a></li>
                        <li><a>Elements</a></li>
                        <li><a>Components</a></li>
                        <li><a>Layout</a></li>
                    </ul>
                </div>
            </nav>
        </div>
    </section>
</div>

和CSS代码:

.header-image {
    background-image: url("http://orig14.deviantart.net/7584/f/2015/181/2/7/flat_mountains_landscape_by_ggiuliafilippini-d8zdbco.jpg");
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    background-color: #999;
}

问题来了,为什么这行不通? 一切都应该按预期工作,stackowerflow 上还有另一篇关于这个问题的帖子,但该帖子的解决方案也行不通!

最佳答案

您的代码在我的本地环境中按预期工作。 您的代码无法正常工作的最可能原因是您忘记或未在 header 中正确链接 Bulma。

关于html - Bulma.io 全高英雄背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45479588/

相关文章:

javascript - 我们可以用 html 元素填充 html 属性吗?

html - CSS:显示: block ;与显示:表格;

user-interface - GUI 框架模式?

javascript - html svg 中的动画脚步

javascript - 使 DIV 风格化为文本区域并包含可编辑的格式化文本

javascript - d3.js 散点图中的刻度标签在 Firefox 13.0.1 中被 chop

ios - (类)不可用 : cannot find swift declaration for this class ONLY for iPhone <= 5 simulator, 通用 iOS 设备和发布版本

Python 网络框架 + [a] 同步任务;长轮询 : not Django

javascript - 添加脚本引用后 HTML 不显示

javascript - 添加滑入式菜单后不再滚动