gpt4 book ai didi

Chrome for Mac 设置背景色后 HTML 按钮变成正方形

转载 作者:搜寻专家 更新时间:2023-10-31 08:06:02 25 4
gpt4 key购买 nike

在 Chrome for Mac 上,为什么设置背景颜色后按钮变成正方形(通常是圆形的)?

<html>
<body>
<input type="button" id="bt1" value="Click me!" onmouseover="this.style.backgroundColor='red;'" onmouseout="this.style.backgroundColor='transparent';">
</body>
</html>

鼠标未悬停在按钮上时的网页:

enter image description here

鼠标悬停在按钮上时的网页:

enter image description here

鼠标经过按钮后的网页:

enter image description here

如何设置背景而不让按钮变成方形?

谢谢。

最佳答案

WebKit/Blink 将按钮绘制为“-webkit-appearance:push-button”,它使用 native API(在本例中为 Cocoa)绘制按钮。然而, native API 不支持任意背景颜色。因此,如果网络作者指定了一些 CSS 属性(例如背景颜色),WebKit/Blink 会自动在内部删除“-webkit-appearance:push-button”并回退到糟糕的 CSS 绘制。

您无法使用 native 按钮外观更改背景颜色。

关于Chrome for Mac 设置背景色后 HTML 按钮变成正方形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21598316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com