【发布时间】:2021-09-26 04:56:32
【问题描述】:
我正在尝试从圆形中获取 css 框阴影,以显示在图像本身下方的导航栏下方。目前我可以让图像创建一个出现在导航栏顶部的阴影,但我希望它看起来是一个对象。
我尝试在“.logo”类上使用 :before 并将阴影放在不同的 z-index 上,但这只会使阴影消失。我对网络东西(以及堆栈溢出)相当陌生,因此将不胜感激。
这是我正在使用的 css,问题在于徽标类
html{
overflow-y: scroll;
}
body {
font-family: "Arial", Helvetica, sans-serif;
font-weight: bold;
font-size: 20px;
color: #DCDCDC;
background-color: #222035;
margin: 0px;
}
.centered {
position: absolute;
left: 50%;
transform: translate(-50%);
}
.logo {
position: relative;
top: 100%;
left: 50%;
transform: translate(-50%, -50%);
width: auto;
height: 100%;
}
.logo:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
border-radius:100%;
box-shadow: 0 2vh 5vh #000000;
}
.topnav {
box-shadow: 0px 2vh 5vh #000000;
width: 100%;
height: 15vh;
background-color: #222035;
}
header {
padding: 170px;
}
以及 HTML 的其余部分
<!DOCTYPE html>
<html lang="en-UK">
<head>
<title>WOW</title>
<link rel="icon" href="icon.png">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav class="topnav">
<img class = "logo" src="icon.png"></nav>
</body>
【问题讨论】:
-
你能分享一个codepen链接吗?
-
也许图像应该只是一个带有
margin: autocodepen.io/toniweb/pen/rNwqRXN的block元素 -
这并没有真正做到我想要的。我仍然希望图像在原处,我只需要阴影在导航栏下方而不是在导航栏上方