#krishnaKanabar - Card Element
1 messages · Page 1 of 1 (latest)
Hi there!
What exactly is the issue? What are you trying to do, and what have you done so far?
hii
we had talk yesterday
i want border like this and other css to be added in card number elements
<span>Card number</span>
<div id="card-number-element" class="el-input"></div>
</label>
<label>
<span>Expiry date</span>
<div id="card-expiry-element" class="field"></div>
</label>
<label>
<span>CVC</span>
<div id="card-cvc-element" class="field"></div>
</label>
this.stripe = Stripe(process.env.STRIPE_PUBLISHABLE_KEY)
let stripeElements = this.stripe.elements()
var style = {
base: {
iconColor: '#666EE8',
color: '#31325F',
lineHeight: '40px',
fontWeight: 300,
fontFamily: 'Helvetica Neue',
fontSize: '15px',
'::placeholder': {
color: '#CFD7E0',
},
},
};
var cardNumberElement = stripeElements.create('cardNumber', {
style: style, showIcon: true
});
cardNumberElement.mount('#card-number-element');
var cardExpiryElement = stripeElements.create('cardExpiry', {
style: style
});
cardExpiryElement.mount('#card-expiry-element');
var cardCvcElement = stripeElements.create('cardCvc', {
style: style
});
cardCvcElement.mount('#card-cvc-element');
.field {
background: transparent;
font-weight: 300;
border: 1px solid !important;
color: #31325F;
outline: none;
flex: 1;
padding-right: 10px;
padding-left: 10px;
cursor: text;
}
border is applying on whole section
Can you share a screenshot of how it looks like right now?
Doyou have a CSS rule that adds a border to the label element?
Instead, you could add a CSS rule like this:
#card-number-element {
border: 1px solid black;
}
When you add this to your HTML: <div id="card-number-element" class="el-input"></div>, then Stripe will automatically add an input inside that div. So if you want to add a border just around the input, then you just need to add a border just around the #card-number-element.
didn't understood
#card-number-element {
border: 1px solid black;
}
this way also it is adding to whole div
Can you try this (just for a test) and show me a screenshot?
#card-number-element {
border: 2px solid red;
}
yeah already tried
same
No, this test has a red border. Can you try that exact code I just shared and show me a screenshot?
👋 taking over for my colleague. Let me catch up.
yes I'm here
Is there any solution for this?
no no
could you please explain then what are you trying to achieve?
i want card number element to look like this
your colleague suggested to add this custom css
#card-number-element {
border: 2px solid red;
}
Ignore what color and px but inshort i want to add border to input element
but border is getting appilied to whole div
this is the result and I want only on input element
you can see inspect element from here
this doesn't work on card element
"The Elements Appearance API doesn’t support individual payment method Elements (such as CardElement). Use the Style object to customize your Element instead."
line from this document
https://stripe.com/docs/js/elements_object/create_element?type=card#elements_create-options-style
https://stripe.com/docs/js/appendix/style
based on the above resources you can't since you don't have the possibility to add borders on the style
but you can add the styles on your own html element
as my colleague explained
To look like this
are you adding the Card number label?
no
<label>
<span>Card number</span>
<div id="card-number-element"></div>
</label>
#card-number-element {
border: 2px solid red;
}
could you try to do something like #card-number-element input{ border....
ok could we try something please?
let's just remove everything else from that page and add step by step
first just add <div id="card-number-element"></div>with the border on #card-number-element
You need to target the specific class on the field, using the correct selector:
.CardNumberField {
border: 1px solid red;
}