按钮 CSS 过滤器仅父级阴影

发布于 2025-01-13 07:31:56 字数 324 浏览 1 评论 0原文

大家好,我需要你们的帮助

,我想这样做: Model Botton

问题是,当我添加一个过滤器

滤镜:drop-shadow(3px 4px 0px #0000B8);

我的按钮的结果是: 我的 Botton

你能帮我吗?

Hello guys i need your help

I want to do that: Model Botton

The problem is that, when i add a filter

filter: drop-shadow(3px 4px 0px #0000B8);

to my button the result is: My Botton

Can you help me please ?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛放△進行李 2025-01-20 07:31:56

有多种方法可以做到这一点。

以下是一些示例:

.button-1 {
  position: relative;
  color: #ff1800;
  background-color: white;
  font-size: 1.2em;
  font-weight: bold;
  border: 2px solid #ff1800;
  padding: 15px;
  border-radius: 100px;
}

.button-1::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: transparent;
  border: 2px solid #ff1800;
  border-radius: 100px;
  filter: drop-shadow(7px 12px 0px #0000B8);
  z-index: -1;
}

.button-2 {
  color: #ff1800;
  background-color: transparent;
  font-size: 1.2em;
  font-weight: bold;
  border: 2px solid #ff1800;
  padding: 15px;
  border-radius: 100px;
  box-shadow: 5px 10px 0 -2px white,
    5px 10px 0 0 #0000B8;
}

.button-3 {
  position: relative;
  color: #ff1800;
  background-color: white;
  font-size: 1.2em;
  font-weight: bold;
  border: 2px solid #ff1800;
  padding: 15px;
  border-radius: 100px;
}

.button-3::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  left: 4px;
  top: 8px;
  right: 0;
  bottom: 0;
  background-color: transparent;
  border: 2px solid #0000B8;
  border-radius: 100px;
  z-index: -1;
}
<button class="button-1">
  Become a seller
</button>

<button class="button-2">
  Become a seller
</button>

<button class="button-3">
  Become a seller
</button>

遗憾的是,这些方法都无法拥有完全透明的背景。

There are multiple ways of doing it.

Here are some examples:

.button-1 {
  position: relative;
  color: #ff1800;
  background-color: white;
  font-size: 1.2em;
  font-weight: bold;
  border: 2px solid #ff1800;
  padding: 15px;
  border-radius: 100px;
}

.button-1::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: transparent;
  border: 2px solid #ff1800;
  border-radius: 100px;
  filter: drop-shadow(7px 12px 0px #0000B8);
  z-index: -1;
}

.button-2 {
  color: #ff1800;
  background-color: transparent;
  font-size: 1.2em;
  font-weight: bold;
  border: 2px solid #ff1800;
  padding: 15px;
  border-radius: 100px;
  box-shadow: 5px 10px 0 -2px white,
    5px 10px 0 0 #0000B8;
}

.button-3 {
  position: relative;
  color: #ff1800;
  background-color: white;
  font-size: 1.2em;
  font-weight: bold;
  border: 2px solid #ff1800;
  padding: 15px;
  border-radius: 100px;
}

.button-3::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  left: 4px;
  top: 8px;
  right: 0;
  bottom: 0;
  background-color: transparent;
  border: 2px solid #0000B8;
  border-radius: 100px;
  z-index: -1;
}
<button class="button-1">
  Become a seller
</button>

<button class="button-2">
  Become a seller
</button>

<button class="button-3">
  Become a seller
</button>

Sadly, none of the methods can have a complete transparent background.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文