如何使 box-shadow 在我的伪元素上工作

发布于 2025-01-20 03:21:33 字数 3079 浏览 1 评论 0原文

尝试修复我的伪元素 ::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,

enter image description here

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;
}

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文