html - <button> Safari 中的额外填充问题

标签 html css button safari padding

示例页面:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Button test</title>
    <style>
      * { border: none; margin: 0; padding: 0; }

      body { padding: 5em; }

      span { background: lightblue; display: inline-block; }

      button { background: red; outline: 1px solid red }
      button div { background: yellow; }

      button::-moz-focus-inner {
        padding: 0;
        border: 0;
      }
      button {
        -webkit-appearance: none;
        -webkit-box-sizing: content-box;
        -webkit-box-align: start;
        -webkit-border-fit: lines;
        -webkit-margin-collapse: discard;
      }
    </style>
  </head>

  <body>
    <span>Adjacent text</span><button><div>Button</div></button>
  </body>
</html>

这是图片:

您可以在按钮中看到额外的白色填充。是否可以在 Safari 浏览器中去除该填充?

最佳答案

晚会有点晚了,但我发现它覆盖了 webkit 边框:

-webkit-border-fit:border !important;

对我来说是一种享受。对 Magento 特别有用 webkit-border-fit属性有时会派上用场,但可能会导致某些问题 <button>的。

关于html - <button> Safari 中的额外填充问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5170041/

相关文章:

javascript - 使用 jquery(或 vanilla JS)在页面加载时格式化表格中的数字

javascript - 使用 Angular (2) routerLinkActive 指令进行变形路由

javascript - jQuery/CSS : How to add page breaks dynamically

css - 我想在 css 中重新创建这个引用

html - Twitter-Bootstrap 按钮在点击后保持悬停状态

JavaScript。 Uncaught ReferenceError : (object) is not defined at HTMLInputElement. onchange

javascript - 如何在另一部分使用 CSS 动画时延迟图像出现

css - Safari flexbox : child of flex container with height:100% overflows when it has a grandchild with height:100%

python - 如何使用 tkinter 使按钮中的文本快速重复变化

Javascript 复制到剪贴板,包括 html 格式的文本