我试图在导航栏中实现一个凸起,导航条应该有一个方框-阴影.然而,在底部也需要它.不知何故,我不能把撞在导航栏后面,这是一个已知的问题,还是我遗漏了什么?非常感谢。
body {
background: beige;
}
.c-header {
background: white;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.8);
height: 60px;
position: fixed;
width: 100%;
z-index: 9999;
}
.c-site-nav {
align-content: center;
display: flex;
justify-content: space-between;
}
.c-site-nav ul {
margin-left: 0;
}
.c-site-nav__item {
display: flex;
justify-content: space-around;
list-style: none;
width: 40%;
}
.c-site-nav__item a {
font-size: 20px;
color: grey;
display: inline-block;
text-decoration: none;
}
.c-logo {
position: absolute;
left: 50%;
transform: translate(-50%, 0);
padding: 0;
position: absolute;
top: 15px;
width: 45px;
z-index: 1;
}
.c-logo::after {
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.8);
position: absolute;
left: 50%;
transform: translate(-50%, 0);
background: white;
border-radius: 50%;
content: '';
height: 60px;
position: absolute;
width: 60px;
z-index: -100;
}<header class="c-header">
<div class="c-logo">
</div>
<nav class="c-site-nav">
<ul class="c-site-nav__item">
<li><a href="/">asd</a></li>
<li><a href="/ueber_uns">asd</a></li>
<li><a href="/">asd</a></li>
</ul>
<ul class="c-site-nav__item">
<li><a href="/">asd</a></li>
<li><a href="/">asd</a></li>
<li><a href="tel:+49234234234">34234234</a></li>
</ul>
</nav>
</header>
发布于 2017-05-15 11:48:40
不好意思,我刚刚意识到了最简单的实现方法,那就是在这个伪元素的上面加上另一个伪元素,这样就可以消除(或掩盖)凸起的阴影。
body {
background: beige;
margin: 0;
}
.c-header {
box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.24), 0 1.5px 6px rgba(0, 0, 0, 0.12);
background: white;
height: 45px;
width: 100%;
z-index: 9999;
}
.c-site-nav {
align-content: center;
display: flex;
justify-content: space-between;
}
.c-site-nav ul {
margin-left: 0;
}
.c-site-nav__item {
display: flex;
justify-content: space-around;
list-style: none;
width: 40%;
}
.c-site-nav__item a {
font-size: 20px;
color: grey;
display: inline-block;
text-decoration: none;
}
.c-logo {
position: absolute;
left: 50%;
transform: translate(-50%, 0);
padding: 0;
position: absolute;
top: 10px;
width: 45px;
z-index: 1;
}
.c-logo::after {
box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.24), 0 1.5px 6px rgba(0, 0, 0, 0.12);
background: white;
border-radius: 50%;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
content: '';
height: 45px;
position: absolute;
width: 60px;
z-index: -1;
}
.c-logo::before {
background: white;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
content: '';
top: -10px;
height: 45px;
position: absolute;
width: 80px;
z-index: 1;
}<header class="c-header">
<div class="c-logo">
</div>
<nav class="c-site-nav">
<ul class="c-site-nav__item">
<li><a href="/">item</a></li>
<li><a href="/">item</a></li>
<li><a href="/">item</a></li>
</ul>
<ul class="c-site-nav__item">
<li><a href="/">item</a></li>
<li><a href="/">item</a></li>
<li><a href="/">item</a></li>
</ul>
</nav>
</header>
发布于 2017-05-15 10:39:51
我不知道这是否是预期的结果,但我成功地通过将
<div class="c-logo">在标头元素的外部。
body {
background: beige;
}
.c-header {
background: white;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.8);
height: 60px;
position: fixed;
width: 100%;
z-index: 9999;
}
.c-site-nav {
align-content: center;
display: flex;
justify-content: space-between;
}
.c-site-nav ul {
margin-left: 0;
}
.c-site-nav__item {
display: flex;
justify-content: space-around;
list-style: none;
width: 40%;
}
.c-site-nav__item a {
font-size: 20px;
color: grey;
display: inline-block;
text-decoration: none;
}
.c-logo {
position: absolute;
left: 50%;
transform: translate(-50%, 0);
padding: 0;
position: absolute;
top: 15px;
width: 45px;
z-index: 1;
}
.c-logo::after {
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.8);
position: absolute;
left: 50%;
transform: translate(-50%, 0);
background: white;
border-radius: 50%;
content: '';
height: 60px;
position: absolute;
width: 60px;
z-index: -100;
}<header class="c-header">
</div>
<nav class="c-site-nav">
<ul class="c-site-nav__item">
<li><a href="/">asd</a></li>
<li><a href="/ueber_uns">asd</a></li>
<li><a href="/">asd</a></li>
</ul>
<ul class="c-site-nav__item">
<li><a href="/">asd</a></li>
<li><a href="/">asd</a></li>
<li><a href="tel:+49234234234">34234234</a></li>
</ul>
</nav>
</header>
<div class="c-logo">
发布于 2017-05-15 10:44:19
您已经为box-shadow circle指定了伪选择器:after上的blur-radius,您可以将该特定元素上的blur-radius缩减如下,
方框-阴影:偏移-x,偏移-y,模糊-半径-颜色
body {
background: beige;
}
.c-header {
background: white;
box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.8);
height: 60px;
position: fixed;
width: 100%;
z-index: 9999;
}
.c-site-nav {
align-content: center;
display: flex;
justify-content: space-between;
}
.c-site-nav ul {
margin-left: 0;
}
.c-site-nav__item {
display: flex;
justify-content: space-around;
list-style: none;
width: 40%;
}
.c-site-nav__item a {
font-size: 20px;
color: grey;
display: inline-block;
text-decoration: none;
}
.c-logo {
position: absolute;
left: 50%;
transform: translate(-50%, 0);
padding: 0;
position: absolute;
top: 15px;
width: 45px;
z-index: 1;
}
.c-logo::after {
box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.8);
position: absolute;
left: 50%;
transform: translate(-50%, 0);
background: white;
border-radius: 50%;
content: '';
height: 60px;
position: absolute;
width: 60px;
z-index: -100;
}<header class="c-header">
<div class="c-logo">
</div>
<nav class="c-site-nav">
<ul class="c-site-nav__item">
<li><a href="/">asd</a></li>
<li><a href="/ueber_uns">asd</a></li>
<li><a href="/">asd</a></li>
</ul>
<ul class="c-site-nav__item">
<li><a href="/">asd</a></li>
<li><a href="/">asd</a></li>
<li><a href="tel:+49234234234">34234234</a></li>
</ul>
</nav>
</header>
https://stackoverflow.com/questions/43977193
复制相似问题