gpt4 book ai didi

html - 无法对齐移动设备的品牌标识、图标和汉堡菜单按钮

转载 作者:太空宇宙 更新时间:2023-11-04 00:52:02 25 4
gpt4 key购买 nike

我是 bootstrap 的新手,所以我还在努力了解它。

我想要实现的是将品牌标志与左侧对齐,并将电话图标和汉堡包导航图标与右侧对齐。它应该看起来像这样:

not aligning correctly for mobile view

可以在这里看到我“错误”使用的代码:

https://www.codeply.com/go/rFsHK3IT8g

如您所见,目前在智能手机 View 中,它们都向左对齐。

如有任何帮助,我们将不胜感激。谢谢。

V

最佳答案

不需要行列结构。只需简单地使用 bootstrap 提供的模板来创建导航栏,它应该可以正常工作,并且因为右侧有 2 个按钮,所以将它们放在 d-flex div 中。

在下面的代码中更新了这部分

<a class="navbar-brand" href="#" style="padding:0px;margin:0;">
<img src="https://certiport.pearsonvue.com/getattachment/Certifications/ESB/Certification/Learn/NFTE_logo_purple_orange.png?lang=en-US">
</a>
<div class="d-flex ml-auto">
<a style="color:#333;height:92px;width:50px; background-color:#F9D049;text-align:center; padding: 26px 0 0 ; margin:0; line-height:1;" href="tel:000-000-000" class="d-block d-md-none">
<i class="fas fa-phone fa-2x"></i>
</a>
<button style="color:#fff;height:92px;width:50px; background-color:#F47227;border-radius:0; padding: 0; margin:0;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false"
aria-label="Toggle navigation">
<i class="fas fa-bars fa-2x"></i>
</button>
</div>

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-md navbar-light bg-light fixed-top" style="padding:0px;margin:0;">
<a class="navbar-brand" href="#" style="padding:0px;margin:0;">
<img src="https://certiport.pearsonvue.com/getattachment/Certifications/ESB/Certification/Learn/NFTE_logo_purple_orange.png?lang=en-US">
</a>
<div class="d-flex ml-auto">
<a style="color:#333;height:92px;width:50px; background-color:#F9D049;text-align:center; padding: 26px 0 0 ; margin:0; line-height:1;" href="tel:000-000-000" class="d-block d-md-none">
<i class="fas fa-phone fa-2x"></i>
</a>
<button style="color:#fff;height:92px;width:50px; background-color:#F47227;border-radius:0; padding: 0; margin:0;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false"
aria-label="Toggle navigation">
<i class="fas fa-bars fa-2x"></i>
</button>
</div>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav ml-auto">

<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Our Team</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Affiliations</a>
</li>
</ul>
</div>
</nav>

<main role="main" class="container">
<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.
<br> All you get is this text and a mostly barebones HTML document.</p>
</div>
</main>

关于html - 无法对齐移动设备的品牌标识、图标和汉堡菜单按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55683168/

25 4 0