gpt4 book ai didi

html - 如何从导航悬垂 "logo"

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

我一直在尝试弄清楚如何使用 SVG 从导航栏悬垂 Logo 。

这是我的代码笔示例:https://codepen.io/Stefan_K/pen/qYweej

HTML/导航栏:

<nav class="navbar navbar-expand-lg">
<a class="navbar-brand">
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>

CSS:

nav {
background-color: firebrick;
}

svg {
position: relative;
top: 70px
}

这个例子是我到目前为止设法做到的。我试图将 Logo (黄色圆圈)悬垂在导航下方 - 一半在里面,一半在外面,并保持导航栏的默认高度。

最佳答案

您可以轻松地做到这一点:

.navbar-brand {
position: absolute;
top: 0px;
}
.navbar-collapse {
margin-left: 115px;
}

并从 svg 中删除所有样式

https://codepen.io/Yulia_pi/pen/vjwELy

关于html - 如何从导航悬垂 "logo",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50494675/

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