中心对齐一个Stripe支付按钮 [重复] 。

问题描述 投票:0回答:1

我的Stripe付款按钮在登陆页面上的居中位置有问题。我已经尝试了页边距,文本对齐和包裹在一个div中,但无济于事。我很抱歉,我的css知识不是很好,但我会感谢你的帮助!

    `<!-- Load Stripe.js on your website. -->
   <script src="https://js.stripe.com/v3"></script> <!-- Create a button that your 
 customers 
  click to complete their purchase. Customize the styling to suit your branding. -->
  <button style="background-color:#FF8800;color:#FFF; padding:8px 12px;border:0;border- 
 radius:4px;font-size:1.5em" id="checkout-button-plan_HBK7An1HxIpxXF" role="link">Start 
Free 
Trial</button>
<div id="error-message">
</div>
<script>
/* <![CDATA[ */
(function() {
 var stripe = Stripe('pk_live_tkRbcnwJtcbR40owQTnDC3E0');

  var checkoutButton = document.getElementById('checkout-button-plan_HBK7An1HxIpxXF');
  checkoutButton.addEventListener('click', function () {
// When the customer clicks on the button, redirect
// them to Checkout.
stripe.redirectToCheckout({
  items: [{plan: 'plan_HBK7An1HxIpxXF', quantity: 1}],

  // Do not rely on the redirect to the successUrl for fulfilling
  // purchases, customers may not always reach the success_url after
  // a successful payment.
  // Instead use one of the strategies described in
  // https://stripe.com/docs/payments/checkout/fulfillment
  successUrl: window.location.protocol + '//accountinguni.com/success',
  cancelUrl: window.location.protocol + '//accountinguni.com/canceled',
})
.then(function (result) {
  if (result.error) {
    // If `redirectToCheckout` fails due to a browser or network
    // error, display the localized error message to your customer.
    var displayError = document.getElementById('error-message');
    displayError.textContent = result.error.message;
    }
  });
 });
  })();
 /*]]>*/
 </script>`
css center
1个回答
-1
投票

试试内嵌样式

 <div style="text-align: center; width: 100%;"><button></button></div>

-1
投票

你可以很容易地使用flex将元素放在中心位置,无论是宽度还是高度。

<div class="center">
    // Your Button
</div>

.center{
    display: flex;
    width: 100%;
    justify-content: center;
}
© www.soinside.com 2019 - 2024. All rights reserved.