gpt4 book ai didi

css - 如何在 anchor 标签内居中放置多个图像

转载 作者:行者123 更新时间:2023-11-28 15:38:44 25 4
gpt4 key购买 nike

我希望图像居中,但无法在超大 屏幕上执行此操作

 <nav class="navbar">
<div class="row">
<div class="col-12 d-flex justify-content-center">
<a href="/html"><img src="./images/devices.png" alt="devices"></a>
<a href="/html"><img src="./images/media.png" alt="media"></a>
<a href="/html"><img src="./images/logo.png" alt="logo"></a>
<a href="/html"><img src="./images/stream.png" alt="stream"></a>
<a href="/html"><img src="./images/logout.png" alt="logout"></a>
</div>
</div>
</nav>

我尝试了 stackoverflow 网站上提供的不同解决方案,但都没有奏效。请帮忙,我是新手

最佳答案

我不太明白你需要什么,但我想你可以引用以下2页:

通常导航是带有多个链接或下拉菜单的栏。所以我看不出这有什么道理。

下面是 2 个示例,其中一个是我水平排列的 .nav 类。一个是我垂直排列的 .navbar 类。

元素的内容居中。

希望这对您有所帮助。

.navbar, .nav {
background-color: #A4A4A4;
border: 1px solid red;
}

/* for the purpose of demonstration, I added borders to the Nav-ul */
#top-menu {
border: 1px solid red;
}

.nav-link {
width: 100px;
text-align: center;
/* for the purpose of demonstration, I added borders to the list items */
border: 1px solid black;
}

.dont_copy_this {height: 50px;}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

<nav class="nav">
<div class="row">
<div class="col-12 d-flex justify-content-center">
<a class="nav-link" href="/html"><img src="./images/devices.png" alt="devices"></a>
<a class="nav-link" href="/html"><img src="./images/media.png" alt="media"></a>
<a class="nav-link" href="/html"><img src="./images/logo.png" alt="logo"></a>
<a class="nav-link" href="/html"><img src="./images/stream.png" alt="stream"></a>
<a class="nav-link" href="/html"><img src="./images/logout.png" alt="logout"></a>
</div>
</div>
</nav>

<div class="dont_copy_this"></div>

<nav class="navbar">
<ul id="top-menu" class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/devices.png" alt="devices"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/media.png" alt="media"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/logo.png" alt="logo"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/stream.png" alt="stream"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/logout.png" alt="logout"></a></li>
</ul>
</nav>

关于css - 如何在 anchor 标签内居中放置多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54866713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com