Background color changes dimensions ???

Can anyone explain me why thus happens ? Is there something in the tailwind I do not understand :/ When I hover over number 2-6 I change border color to yellow and then the size looks same with number 1 which is active with yellow background. I set container grid grid-cols-[repeat(3,min(50px))] grid-rows-[repeat(2,min(50px))] place-self-center gap-4 that holds those 6 buttons with p tag and number. After checking developer tools the computed style size is same 48px and 1px border * 2 sides = 50px in total for both active and non-active buttons. I am very confused as to why this is happening.
No description
9 Replies
Psyzen
Psyzen5mo ago
Oh and when I hover over active number 1 in developer tools it almost looks like it overflows content outside the container.
Jochem
Jochem5mo ago
borders are added on top of the existing size. The 1 probably has a border set, and the hover then adds that border to 2-6 if that's not it, share your code. Tailwind has an excellent playground, or otherwise you can use codepen
Psyzen
Psyzen5mo ago
Alright. Thank you. I removed all borders and it didn't seem to help it only worked when I removed active color. Here is the section of code that does it. I may be missing the point. Take a look if you understand tailwind.
<div class="grid grid-cols-[repeat(3,min(50px))] grid-rows-[repeat(2,min(50px))] place-self-center gap-4">
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded active [&.active]:bg-[#FDD700] [&.active]:hover:bg-opacity-90 [&:not(active)]:hover:border-[#FDD700]">
<p class="place-self-center">1</p>
</buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">2</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">3</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">4</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">5</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">6</p></buttons>
</div>
<div class="grid grid-cols-[repeat(3,min(50px))] grid-rows-[repeat(2,min(50px))] place-self-center gap-4">
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded active [&.active]:bg-[#FDD700] [&.active]:hover:bg-opacity-90 [&:not(active)]:hover:border-[#FDD700]">
<p class="place-self-center">1</p>
</buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">2</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">3</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">4</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">5</p></buttons>
<buttons class="grid bg-[#1A1A1A] border border-solid border-[hsla(0,0%,100%,0.1)] rounded hover:border-[#FDD700]"><p class="place-self-center">6</p></buttons>
</div>
There also could be a hidden issue I do not understand when I try to increase border-width to like 5px the border is not outside but inside container expanding almost like inset and when I do hover:border-[yellow(#FDD700)] the border works as you mentioned outside container.
Psyzen
Psyzen5mo ago
Here is visual aspect when I increase border width to 8px
No description
Psyzen
Psyzen5mo ago
I may be wrong but I think the #FDD700 color makes it seem bigger then it is. I only set one border width and the only thing I do is change color.
Jochem
Jochem5mo ago
yeah, looks like an optical illusion:
No description
Psyzen
Psyzen5mo ago
Thank you for this image. Wasted so much time. May I ask what tool is that ?
Jochem
Jochem5mo ago
it's part of snipping tools in windows you can also just look at the computed size in devtools, but you didn't link a live version so I couldn't do that
Psyzen
Psyzen5mo ago
Sorry, I didn't post it because the size was exactly the same.
Want results from more Discord servers?
Add your server
More Posts