gpt4 book ai didi

html - 如何使用 Bootstrap 对齐图标旁边的文本?

转载 作者:太空宇宙 更新时间:2023-11-04 05:37:14 24 4
gpt4 key购买 nike

我正在尝试对齐此图标旁边的文本,但图标不想合作。开个玩笑……我对前端完全是菜鸟,尤其是 Bootstrap 。谁能告诉我怎么做?

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">

<li class="active">
<a href="#"><span class="fa fa-database mr-3"></span> Menedżer baz danych</a>
</li>
<li>
<a href="#"><span class="fas fa-project-diagram mr-3"></span> Menedżer diagramów ER</a>
</li>
<li>
<a href="#"><span class="fa fa-folder-open mr-3"></span> Katalog diagramów ER</a>
</li>
<li>
<a href="#"><span class="fa fa-trophy mr-3"></span> Top Review</a>
</li>
<li>
<a href="#"><span class="fa fa-cog mr-3"></span> Settings</a>
</li>
<li>
<a href="#"><span class="fa fa-support mr-3"></span> Support</a>
</li>
<li>
<a href="#"><span class="fa fa-sign-out mr-3"></span> Wyloguj</a>
</li>

真实的样子:

enter image description here

最佳答案

这可能是一个好的开始。请注意 li 应始终位于 ul 内。

ul {
list-style: none;
}
li {
padding: 0.5em;
background: black;
}
li:hover {
background: blue;
}
li > a {
display: flex;
color: white;
text-decoration: none;
}
li > a > span {
min-width: 30px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">
<ul>
<li class="active">
<a href="#"><span class="fa fa-database mr-3"></span> Menedżer baz danych</a>
</li>
<li>
<a href="#"><span class="fas fa-project-diagram mr-3"></span> Menedżer diagramów ER</a>
</li>
<li>
<a href="#"><span class="fa fa-folder-open mr-3"></span> Katalog diagramów ER</a>
</li>
<li>
<a href="#"><span class="fa fa-trophy mr-3"></span> Top Review</a>
</li>
<li>
<a href="#"><span class="fa fa-cog mr-3"></span> Settings</a>
</li>
<li>
<a href="#"><span class="fa fa-support mr-3"></span> Support</a>
</li>
<li>
<a href="#"><span class="fa fa-sign-out mr-3"></span> Wyloguj</a>
</li>
</ul>

关于html - 如何使用 Bootstrap 对齐图标旁边的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59523475/

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