悬停在悬停的野生动物园元素,没有填充整个区域

发布于 2025-02-14 00:08:16 字数 1406 浏览 3 评论 0原文

为什么在野生动物园(ON:悬停)中,整个按钮不转到我的悬停颜色

(我认为填充有问题)

---结果safari:

”在此处输入图像描述”

---导致Chrome(预期):

.btn,
a.btn{
    background-color: #027BFF;
    border-color: #007bff;
    color: #fff;
    border-radius: 0;
    padding: 42px 20px;
    transition: color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,box-shadow .2s ease-in-out;
    transition-property: color, background-color, border-color, box-shadow;
    transition-duration: 0.2s, 0.2s, 0.2s, 0.2s;
    transition-timing-function: ease-in-out, ease-in-out, ease-in-out, ease-in-out;
    transition-delay: 0s, 0s, 0s, 0s;
}

.btn:hover, a.btn:hover {
    background-color: pink;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 5%);
    cursor: pointer;
}
<a href="#" class="btn btn-primary" onclick="javascript: something()"><span>Search</span></a>

Why in Safari (on :hover) not the whole button turns to my hover-color ?

(Something wrong with padding I assume)

--- Result in Safari:

enter image description here

--- Result in Chrome (expected):

enter image description here

.btn,
a.btn{
    background-color: #027BFF;
    border-color: #007bff;
    color: #fff;
    border-radius: 0;
    padding: 42px 20px;
    transition: color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,box-shadow .2s ease-in-out;
    transition-property: color, background-color, border-color, box-shadow;
    transition-duration: 0.2s, 0.2s, 0.2s, 0.2s;
    transition-timing-function: ease-in-out, ease-in-out, ease-in-out, ease-in-out;
    transition-delay: 0s, 0s, 0s, 0s;
}

.btn:hover, a.btn:hover {
    background-color: pink;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 5%);
    cursor: pointer;
}
<a href="#" class="btn btn-primary" onclick="javascript: something()"><span>Search</span></a>

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

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

发布评论

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

评论(2

白昼 2025-02-21 00:08:16

我在Safari中对:Hover也有类似的问题。在悬停时,我的按钮并未像您的示例那样完全填充。

我将错误缩小到我的font-family

body {font-family:inter,'arial narrow narrow bold',sans-serif; }

我已经通过fonts.bunny.net导入Inter Inter,如果我删除Inter并使用系统字体:Hover的行为,则按预期行为。当我使用导入字体的那一刻,问题又回来了。

我能够通过使用切换到Google字体而不是fonts.bunny.net 来完全修复它。

I was having a similar issue with :hover in Safari. On hover, my a button was not filling in completely like your example.

I narrowed the bug down to my font-family:

body { font-family: Inter, 'Arial Narrow Bold', sans-serif; }

I have Inter imported via fonts.bunny.net and if I remove Inter and use a system font the :hover behaves as expected. The moment I use an imported font, the issue comes back.

I was able to fix it completely by using switching to Google Fonts instead of fonts.bunny.net

三生路 2025-02-21 00:08:16

问题似乎是出于野生动物园的处理 box -shadow - &gt;

.btn,
a.btn{
    background-color: #027BFF;
    border-color: #007bff;
    color: #fff;
    border-radius: 0;
    padding: 42px 20px;
    transition: color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,box-shadow .2s ease-in-out;
    transition-property: color, background-color, border-color, box-shadow;
    transition-duration: 0.2s, 0.2s, 0.2s, 0.2s;
    transition-timing-function: ease-in-out, ease-in-out, ease-in-out, ease-in-out;
    transition-delay: 0s, 0s, 0s, 0s;
}

.btn:hover, a.btn:hover {
    background-color: pink;
    color: #fff;
    /* box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 5%); */
    cursor: pointer;
}
<a href="#" class="btn btn-primary" onclick="javascript: something()"><span>Search</span></a>

The problem seems to be with Safari's handling of box-shadow ->

.btn,
a.btn{
    background-color: #027BFF;
    border-color: #007bff;
    color: #fff;
    border-radius: 0;
    padding: 42px 20px;
    transition: color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,box-shadow .2s ease-in-out;
    transition-property: color, background-color, border-color, box-shadow;
    transition-duration: 0.2s, 0.2s, 0.2s, 0.2s;
    transition-timing-function: ease-in-out, ease-in-out, ease-in-out, ease-in-out;
    transition-delay: 0s, 0s, 0s, 0s;
}

.btn:hover, a.btn:hover {
    background-color: pink;
    color: #fff;
    /* box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 5%); */
    cursor: pointer;
}
<a href="#" class="btn btn-primary" onclick="javascript: something()"><span>Search</span></a>

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