如何使 box-shadow 在我的伪元素上工作
尝试修复我的伪元素 ::after
上的 box-shadow,但即使我遵循 stackoverflow 示例,它也不起作用,如下所示:将 box-shadow 添加到 :after 伪元素
尝试过多种方法,但似乎没有任何效果,
我的代码:
<template>
<div>
<div class="markar-container">
<button>
<h1>Pin</h1>
<div class="outer-circle">
<div class="inner-circle">
<div class="text">AA</div>
</div>
</div>
</button>
</div>
</div>
</template>
<style scoped>
.markar-container {
box-sizing: border-box;
}
.outer-circle {
position: relative;
width: 60px;
height: 60px;
border-radius: 50%;
background-color: #fff;
box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.3);
}
.outer-circle:hover {
background: black;
}
.inner-circle {
width: 52px;
height: 52px;
border-radius: 35px;
background: #3ac371;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.text {
position: absolute;
left: 10px;
top: 11px;
font-size: 22px;
color: white;
}
.outer-circle::before {
content: "";
top: 51px;
left: 15px;
border-width: 16px;
border-style: solid;
border-color: transparent #fff transparent transparent;
/* box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.3); */
/* box-shadow: 2px rgba(0, 0, 0, 0.91); */
position: absolute;
transform: rotate(-90deg);
}
.outer-circle::after {
/* tried this example1, doesnot works */
/* position: absolute;
content: "";
top: 73px;
left: 30px;
border-width: 10px;
transform: rotate(45deg);
z-index: -1;
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.75); */
/* tried this example2, doesnot works */
/* content: "";
position: absolute;
transform: rotate(45deg);
width: 36px;
height: 36px;
bottom: -4px;
left: 22px;
z-index: -1;
box-shadow: 0px 3px 3px 0 rgba(0, 0, 0, 0.4); */
/* tried this example3, doesnot works */
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -7px;
bottom: -10px;
left: 50%;
box-sizing: border-box;
border: 5px solid black;
border-color: transparent transparent #fff #fff;
transform-origin: 0 0;
transform: rotate(-45deg);
box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
}
.outer-circle:hover:before {
border-right-color: black;
}
.inner-circle:hover {
background: #9f1853;
}
</style>
此外,尝试在周围获得一些漂亮的银色边框颜色,但失败了,如下图所示,通过在两个选择器中提供选择器样式:
.dl-outer-circle {
border: 2px solid silver;
}
.dl-outer-circle::before {
border: 2px solid silver;
}
Trying to fix box-shadow on my pseudo element ::after
, but its not working even though I followed stackoverflow examples, like this one: Adding box-shadow to a :after pseudo element
Did try to do in several ways but nothing seems to work,
My code for this:
<template>
<div>
<div class="markar-container">
<button>
<h1>Pin</h1>
<div class="outer-circle">
<div class="inner-circle">
<div class="text">AA</div>
</div>
</div>
</button>
</div>
</div>
</template>
<style scoped>
.markar-container {
box-sizing: border-box;
}
.outer-circle {
position: relative;
width: 60px;
height: 60px;
border-radius: 50%;
background-color: #fff;
box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.3);
}
.outer-circle:hover {
background: black;
}
.inner-circle {
width: 52px;
height: 52px;
border-radius: 35px;
background: #3ac371;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.text {
position: absolute;
left: 10px;
top: 11px;
font-size: 22px;
color: white;
}
.outer-circle::before {
content: "";
top: 51px;
left: 15px;
border-width: 16px;
border-style: solid;
border-color: transparent #fff transparent transparent;
/* box-shadow: 2px 2px 3px 2px rgba(0, 0, 0, 0.3); */
/* box-shadow: 2px rgba(0, 0, 0, 0.91); */
position: absolute;
transform: rotate(-90deg);
}
.outer-circle::after {
/* tried this example1, doesnot works */
/* position: absolute;
content: "";
top: 73px;
left: 30px;
border-width: 10px;
transform: rotate(45deg);
z-index: -1;
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.75); */
/* tried this example2, doesnot works */
/* content: "";
position: absolute;
transform: rotate(45deg);
width: 36px;
height: 36px;
bottom: -4px;
left: 22px;
z-index: -1;
box-shadow: 0px 3px 3px 0 rgba(0, 0, 0, 0.4); */
/* tried this example3, doesnot works */
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -7px;
bottom: -10px;
left: 50%;
box-sizing: border-box;
border: 5px solid black;
border-color: transparent transparent #fff #fff;
transform-origin: 0 0;
transform: rotate(-45deg);
box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
}
.outer-circle:hover:before {
border-right-color: black;
}
.inner-circle:hover {
background: #9f1853;
}
</style>
Also, tried to get some nice looking silver border color around and failed to do so, like below image by giving the selectors style in both selectors:
.dl-outer-circle {
border: 2px solid silver;
}
.dl-outer-circle::before {
border: 2px solid silver;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论