如何让一个圆润的div与圆润的导航条相适应?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何让一个圆润的div与圆润的导航条相适应?相关的知识,希望对你有一定的参考价值。
我想让那个红色的div与导航条的边角和高度相适应。我一直在使用bootstrap组件,并试图适应我想要的东西.如果有一种方法使用一个按钮,而不是一个DIV将被罚款,我只是想让它与导航栏的大小相适应。
这是我的代码片段
.container {
min-height: 100vh;
padding: 2rem 1rem;
}
.navbar {
z-index: -1;
width: 70%;
margin: 0 auto;
border-radius: 20rem;
}
.nav-item {
padding: 0;
}
.book-now {
overflow: visible;
z-index: 100;
background-color: rgba(255, 48, 48, 1);
height: match-parent;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<header class="container">
<nav class="navbar bg-dark navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="">MOTRAVELS</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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="">CITIES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">PLACES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">EVENTS</a>
</li>
<div id="book-now">
<a class="nav-link" href="">BOOK NOW</a>
</div>
</ul>
</div>
</nav>
</header>
答案
可能是这样的?
.container {
min-height: 100vh;
padding: 2rem 1rem;
}
.navbar {
z-index: -1;
width: 70%;
margin: 0 auto;
border-radius: 20rem;
}
.nav-item {
padding: 0;
}
.nav-item:last-child {
background-color: rgba(255, 48, 48, 1);
height: match-parent;
border-radius: 0rem 25rem 25rem 0rem;
margin-right: -0.5rem;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<header class="container">
<nav class="navbar bg-dark navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="">MOTRAVELS</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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="">CITIES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">PLACES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">EVENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">BOOK NOW</a>
</li>
</ul>
</div>
</nav>
</header>
以上是关于如何让一个圆润的div与圆润的导航条相适应?的主要内容,如果未能解决你的问题,请参考以下文章
如何制作更圆润的 UITextField?就像 iPad 上 Safari 中的搜索栏