CSS keeps adding an unnecessary gap

Right, so I've made a div with an input and button. Here is the CSS: .subscribe-box { background-color: var(--clr-light_2); padding: 0.4rem; border-radius: 100rem; display: flex; gap: 1rem; width: min-content; } .subscribe-box input { background-color: transparent; border: 2px solid var(--clr-light_1); border-radius: 100rem; padding: 0.3rem; } .subscribe-box button { border-radius: 100rem; padding: 0.3rem; background-color: var(--clr-primary); border: none; color: var(--clr-light_1); } Here is the markup: <div class="subscribe-box"> <input type="email" placeholder="Email Address" /> <button>Subscribe</button> </div> The problem is that the gap is applied to both the left and right side of the button. Theoretically, as there are only 2 elements in the div, only the left-side gap should exist. What could be causing this?
18 Replies
Lord Of Insanity
Lord Of InsanityOP9mo ago
Here is a codepen with the problem: https://codepen.io/BravoLima2k4/pen/PogzbyY
majkl
majkl9mo ago
What gap do you mean? There is a margin on the body, right? https://codepen.io/Ghloo/pen/rNbLmYm
Lord Of Insanity
Lord Of InsanityOP9mo ago
The gap property for flex and grid. And on my actual project I nuked the margins
majkl
majkl9mo ago
I know, thought you meant it more broadly. I see no suspect gap in the pen. After nullifying the body margin it looks ok to me in my pen fork.
Lord Of Insanity
Lord Of InsanityOP9mo ago
This is the gap I mean, and this is it in chrome dev tools. You can see a hatch box denoting a gap on both sides of the button
No description
No description
CodeNascher
CodeNascher9mo ago
no gap on the right for me. browsers used for testing (mobile): - firefox - chrome - kiwi - opera - samsung internet
majkl
majkl9mo ago
In the pen, there is a "Subscribe" button (seee my pen link), which works good in FF, Chrome and Vivaldi.
CodeNascher
CodeNascher9mo ago
looks the same for me with OP's codepen link
CodeNascher
CodeNascher9mo ago
from firefox mobile
No description
CodeNascher
CodeNascher9mo ago
looks the same in all browsers i tested. no idea how to troubleshoot this if the problem doesn't even exist on my end...
majkl
majkl9mo ago
You meaan in the pen or in a live website?
Kevin Powell
Kevin Powell9mo ago
It's LastPass causing the problem It inserts an element to create the icon, and because the parent is display: flex, it's creating a new column, and so there is an extra gap
Kevin Powell
Kevin Powell9mo ago
No description
Kevin Powell
Kevin Powell9mo ago
It's just lazy coding on LastPass. They give it a width and height of 0, so that it shouldn't impact layouts, but it's still there, and in the dom, so if it's 0x0, it exists, and so is a flex child and gets it's own column
CodeNascher
CodeNascher9mo ago
ah, the icon was my suspicion as well, because it's missing in the pen but visible in the screenshot. i thought it maybe was a pseudo element and the code wasn't provided. but that lastpass thing is just silly smh
Lord Of Insanity
Lord Of InsanityOP9mo ago
Yep, disabling the extension fixes it. Are there any ways that you know to fix it without turning off the extension?
Kevin Powell
Kevin Powell9mo ago
You could try styling the [data-lastpass-icon-root], but it might simply break the icon completely. It's hard, because the position: relative is both inline, and !important... yup, but because LastPass is injecting an element (as you can see in the screenshot), that element is creating a new column of content. The element is 0x0, but it's there, so it creates a 0px wide column, but that also means there's now an extra gap
Want results from more Discord servers?
Add your server