如何将 Bootstrap 4 导航栏中的品牌标志设置为左边缘? [英] How to set the brand logo in Bootstrap 4 navbar to the left edge?

查看:35
本文介绍了如何将 Bootstrap 4 导航栏中的品牌标志设置为左边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的标志.

</nav>

Bootstrap 在左侧添加了一块填充,从而导致与边缘的以下偏移.

由于我们的标志是一个截断的圆,我们希望它精确地放置在边缘,以创造一个真正的圆的错觉,但它会粘在浏览器之外.我试图在左侧设置一个负边距,但它只移动了图像,仍然保留了如下所示的奇怪边缘.

<img class="navbar-brand" src="logo.png" alt="logo" style="margin-left: 0px;">

我该怎么办?

解决方案

您可以使用 row 代替 container-fluid.这两个具有相反的边距.

https://jsfiddle.net/gsb3ohd2/

</nav>

I have a logo as shown below.

<nav class="navbar navbar-fixed-top navbar-light bg-primary">
  <div class="container-fluid">
    <img class="navbar-brand" src="logo.png" alt="logo">
    <ul class="nav navbar-nav">
      <li class="nav-item"><a href="#" class="nav-link">START</a></li>
      ...
    </ul>
  </div>
</nav>

Bootstrap adds a piece of padding on the left resulting in the following offset from the edge.

Since our logo is a cut off circle, we want it to be placed precisely at the edge to create illusion of a real circle but sticking outside of the browser. I've tried to set a negative margin on the left side but it only moved the image, still retaining the weird edge as shown below.

<img class="navbar-brand" src="logo.png" alt="logo" style="margin-left: 0px;">

What can I do about it?

解决方案

You can use row instead of container-fluid. these two have opposite margins.

https://jsfiddle.net/gsb3ohd2/

<nav class="navbar navbar-fixed-top navbar-light bg-primary">
  <div class="row">
    <img class="navbar-brand" src="logo.png" alt="logo">
    <ul class="nav navbar-nav">
      <li class="nav-item"><a href="#" class="nav-link">START</a></li>
      ...
    </ul>
  </div>
</nav>

这篇关于如何将 Bootstrap 4 导航栏中的品牌标志设置为左边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆