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