<img/>混淆了navbar-brand size |引导

时间:2018-01-19 16:50:42

标签: html css html5 bootstrap-4 navbar

我遇到的问题是,在引导程序中,如果我将图像放入<a class="navbar-brand">,它就会混淆所有内容。

<!-- Nav -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
    <a class="navbar-brand" href="#">
        <img src="img/bee-1000sqr.png" class="bnav-bee" style="padding-right: -100px;" />
        Bienenkamera
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href="#">Home</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
        </ul>
        <form action="http://www.lugy-online.de/" method="get">
            <button class="btn btn-primary my-2 my-sm-0" type="submit">Zurück zum LuGy</button>
        </form>
    </div>
</nav>
<!-- /Nav -->

<a class="navbar-brand">内部导致导航栏品牌<a> - 标签变宽,我的按钮太正确的问题,如果我调整浏览器窗口的大小,导航栏切换器是在navbar-brand下面。

你能帮助我吗?

.bnav-bee {
    max-width: 4%;
    margin-top: -10px;
}

我已经尝试在<a> - 标签中使用宽度样式(css)修复它,我试图弄乱填充或边距。这些都没有奏效。

1 个答案:

答案 0 :(得分:0)

指定图像的宽度和高度,如下例所示。

对于间距使用native Bootstrap padding and margin classes,例如px-*pl-*mx-*等。

以下是代码段:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">


<!-- Nav -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
    <a class="navbar-brand" href="#">
        <img src="https://placehold.it/60" width="30" height="30" class="bnav-bee">
        Bienenkamera
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href="#">Home</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
        </ul>
        <form action="http://www.lugy-online.de/" method="get">
            <button class="btn btn-primary my-2 my-sm-0" type="submit">Zurück zum LuGy</button>
        </form>
    </div>
</nav>
<!-- /Nav -->


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>