我試圖在導航欄中實現凹凸,導航欄應該有一個方塊陰影...但是凹凸也需要它在底部...不知何故,我不能把導航欄後面的凹凸,這是一個已知的問題,或者我錯過了什麼?非常感謝。將陰影和z索引應用於絕對定位的元素
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>
這是正確的解決方案 – pokeybit
或刪除z-index:9999;從頭文件css – pokeybit
謝謝@kevin我剛纔意識到整個想法不可能像這樣實現,因爲很明顯,來自酒吧的陰影現在也在凹凸處 – HendrikEng