本文介绍了具有图像背景的Bootstrap主标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的主标题,其中包含一个导航栏,我想要主标题的图像背景.

I have a simple main header which contain a navbar , I want an image background to the main header.

这是jsfidle: http://jsfiddle.net/Mwanitete/fgkq759n/8/

Here is jsfidle:http://jsfiddle.net/Mwanitete/fgkq759n/8/

这是html:

   <div class="marketing-main-header_banner">
            <nav class="navbar navbar-expand-lg navbar-light bg-light">
                <a class="navbar-brand" href="#">Navbar</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
                    aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarNav">
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item active">
                            <a class="nav-link" href="#">Dla kogo <span class="sr-only">(current)</span></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Agenda</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Prowadzacy</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Faq</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Kontakt</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Kompetencje</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>

这是CSS

html, body{
    height: 100%;
    margin: 0px;
}
* {
    box-sizing: border-box;
}
.marketing-main-header_banner{
    background-image: url("https://thumb.ibb.co/eodzqU/Path_47.png" alt="Path_47");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 100% 100%;
    position: relative;
    height: 900px;

}

这是我所拥有的:

我的解决方案在顶部显示导航栏,而图像是否在导航栏下方?

my solution displays navbar on top and the image is below the navbar?

这就是我想要的:

我的代码中缺少什么?

推荐答案

您可以尝试使用此代码,希望它能正常工作!

You can try with this code i hope it's will work!

<div class="marketing-main-header_banner">
            <nav class="navbar fixed-top navbar-light bg-light">
                <a class="navbar-brand" href="#">Navbar</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
                    aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarNav">
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item active">
                            <a class="nav-link" href="#">Dla kogo <span class="sr-only">(current)</span></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Agenda</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Prowadzacy</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Faq</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Kontakt</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Kompetencje</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>

这篇关于具有图像背景的Bootstrap主标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!