【问题标题】:How change border-radius in apple-pay buttom (Safari)如何更改苹果支付按钮(Safari)中的边框半径
【发布时间】:2020-01-17 02:15:34
【问题描述】:

默认苹果支付按钮边框半径 5px/ 我需要将它设置为 15px。我如何才能更改此属性?当我设置

border-radius: 15px;
到类 .apple-pay-button,按钮不会改变

有代码示例:

@supports (-webkit-appearance: -apple-pay-button) { 
    .apple-pay-button {
        display: inline-block;
        -webkit-appearance: -apple-pay-button;
    }
    .apple-pay-button-black {
        -apple-pay-button-style: black;
    }
    .apple-pay-button-white {
        -apple-pay-button-style: white;
    }
    
    .apple-pay-button-white-with-line {
        -apple-pay-button-style: white-outline;
    }
}
@supports not (-webkit-appearance: -apple-pay-button) {
    .apple-pay-button {
        display: inline-block;
        background-size: 100% 60%;
        background-repeat: no-repeat;
        background-position: 50% 50%;
        border-radius: 5px;
        padding: 0px;
        box-sizing: border-box;
        min-width: 200px;
        min-height: 32px;
        max-height: 64px;
    }
    .apple-pay-button-black {
        background-image: -webkit-named-image(apple-pay-logo-white);
        background-color: black;
    }
    .apple-pay-button-white {
        background-image: -webkit-named-image(apple-pay-logo-black);
        background-color: white;
    }
    .apple-pay-button-white-with-line {
        background-image: -webkit-named-image(apple-pay-logo-black);
        background-color: white;
        border: .5px solid black;
    } 
}
<div class="apple-pay-button apple-pay-button-white"></div>

有来自Apple的代码官方文档 https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons

谢谢

【问题讨论】:

  • 这段代码没有显示任何东西,你能检查一下吗?
  • 如果您尝试从非 Mac 或 IOS 操作系统启动此代码,它将无法正常工作
  • 解决这个问题的方法之一是使用父组件并设置它需要的边框半径和大小,就像苹果按钮一样。但我想知道,是否还有其他方法可以设置此按钮的样式

标签: css safari applepay applepayjs


【解决方案1】:

对我有用的是为按钮的 css 添加背景颜色。就我而言,我使用的是黑色按钮样式。

在 iOS 13.3.1 上测试

@supports (-webkit-appearance: -apple-pay-button) { 
    button.apple-pay-button {
        display: inline-block;
        -webkit-appearance: -apple-pay-button;
        background: #000;
        border-radius: 20px;
    }
    .apple-pay-button-black {
        -apple-pay-button-style: black;
    }
}

亲切的问候,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-15
    • 2022-11-11
    • 2021-10-01
    • 2017-07-29
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 2012-03-26
    相关资源
    最近更新 更多