html - css/Bootstrap 4 - 按视口(viewport)居中

标签 html css bootstrap-4

我是 html/css/bootstrap 4 的新手,目前正在创建导航栏。基本上我想要一个 youtube 标志,它在左边重定向到一个 yt channel ,spotify 标志在右边 spotify 创作者,在中间是创作者的名字,这是一个用于导航网站的下拉菜单。不知何故,我设法做到了这一点,但有一个异常(exception)——创作者的名字没有以视口(viewport)为中心,所以当我创建一个标题时,它们没有水平对齐——名字有点偏离中心(向右)。我该如何去中心化它? - The items both have different centers - image.

我的乱码:

<nav class="navbar navbar-light bg-black">
  <a class="nav-link" style="color:white" href="https://www.youtube.com/channel/UC_OvfkWfYRvdkazcOoeJd8Q"><img src="img/yt-logo-dark.png" alt="YouTube" height="25px"></a>
  <ul class="nav justify-content-center">
    <li class="nav-item dropdown">
      <a class="nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" style="color:white"><h2>KJK Music</h2></a>
      <div class="dropdown-menu">
        <a class="dropdown-item disabled" href="about-me">O mně</a>
        <div class="dropdown-divider"></div>
        <a class="dropdown-item disabled" href="about-site">O stránce</a>
      </div>
     </li>
    </ul>
    <a class="navbar-link" style="color: white" href="https://open.spotify.com/artist/7vlBedEBJhQlJCl1tpknhi"><img src="img/SpotifyIcon.png" alt="Spotify" height="50px" style="margin:12.5px"></a>
</nav>

(必须作为一个片段来做,否则格式会更奇怪)

最佳答案

如果你想让“KJK Music”水平居中,它已经居中,因为你的标签有 justify-content-center 类。 + 您可以使用“text-center”类使其水平居中或使用 text-align:center CSS 属性。

关于html - css/Bootstrap 4 - 按视口(viewport)居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54793818/

相关文章:

html - 下拉菜单不会在移动 View 中滚动

css - Angular 5中单独模块的单独样式

javascript - 如何从输入中获取数字并按从大到小的顺序排列

html - css: Bootstrap 下拉菜单右对齐图标

javascript - 如何使用 jquery 从动态添加的表中删除没有 id 的特定 <td> 单元格?

css - 有没有办法在 css 中自动缩进嵌套部分?

html - WOW js动画重复不起作用

javascript - 如何在不影响页面布局的情况下使用 jQuery 扩展框大小

html - 导航栏图标栏动画错误

javascript - UTC 实时时钟,不适用于负时区