intersecting borders

How can I prevent div borders from being accumlated on top of each other like here https://codepen.io/sos909/pen/GRLPyzy The border between the 2 divs is wider than all the other sides, how can I make it consistent
SOS909
CodePen
GRLPyzy
...
22 Replies
ἔρως
ἔρως3mo ago
try margin: -1px on the 2nd div
sos
sos3mo ago
That works but I have alot of divs so I want something that works without having to manually add margin for specific divs I tried using outline instead of borders and it works but when I added background-color the width of the outline decreases for some reason
sos
sos3mo ago
This is using outline
No description
sos
sos3mo ago
see how the top side of the div is thinner than the bottom
outline: 2px solid black;
background-color: orange;
outline: 2px solid black;
background-color: orange;
These are the only styles being appiled to that element
ἔρως
ἔρως3mo ago
the outline is "outside" the size of the element what you can do is skip the border border-collapse seems to only work on tables
sos
sos3mo ago
wdym by skip the border
ἔρως
ἔρως3mo ago
border-top: none
clevermissfox
clevermissfox3mo ago
Box-shadow is another one you could try, like outline it doesn’t take up space.
ἔρως
ἔρως3mo ago
or border-top-width: 0 the downside of those is that it doesn't take up space
Tok124 (CSS Nerd)
You can do this
No description
Tok124 (CSS Nerd)
Or this
No description
ἔρως
ἔρως3mo ago
the top one is easier to read instead of .box + .box, you can use .box + * it's slightly different, but for this example it does the same oh, another idea: margins collapse, so, set a background to the parent element and set a different background for the .box with a margin
sos
sos3mo ago
I tried adding z-index: -1 to all my colored divs and now its working It was something with the order of displaying I think using outlines btw
ἔρως
ἔρως3mo ago
DO NOT DO THAT! that is an horrible idea
sos
sos3mo ago
what why
ἔρως
ἔρως3mo ago
NEVER EVER EVER GO NEGATIVE unless you know what you're doing it introduces tons of issues mostly: anything and everything will get in front of it, the background won't work properly and other weird stuff will happen
sos
sos3mo ago
what if I set z-index: 100 to all my uncolored divs
ἔρως
ἔρως3mo ago
that's bad it will get in front of other stuff you will then be fighting to keep menus and other things on top in the end, you will be setting z-index: 99999999999999999999 to everything you want always on top which is also very bad
MarkBoots
MarkBoots3mo ago
if possible for your use case. i would wrap it in a separate div. and give that wrapper an outline with the same width
No description
ἔρως
ἔρως3mo ago
that works, but limits the outline usage
MarkBoots
MarkBoots3mo ago
or shadow or border
ἔρως
ἔρως3mo ago
however, you should never have focus on a div, so, it's fine
Want results from more Discord servers?
Add your server
More Posts
Scroll Animation with Dynamic Image change want to be more reactiveHi there, I'm new but I'm needing some help with my scroll animating. For the most part, what I haveGit repo 'rebasing' message in terminal: "Please enter the commit message for your changes"I've been trying to push to a remote repo, and I'm being hit with this message in the terminal (see How to remove whitespace when zoomed near scroll barIm using tailwind, when i zoom near the scrollbar there is small whitespace next to it, how do i remVideo with source webm not looping in safariI'm having a video tag used as background video, which is working great in all browsers – except safUsing React Query with SSR Next js 14 App RouterHello. I would like to know if it is possible to use React Query in Next js 14 App Router in Server Achieving Consistent Blur Effects Across Different Browsers: A GuideCould someone please advise me on why the blur effect doesn't appear consistent across all browsers get Text and link (if exists) when users highlight text on screen.Hi guys, I wonder that how can I get text and the link when users highlight it on screen? I got the Need help with the Tab active stateso i have this 4 sections with the tab on the top of it. what i want to do is i want tomake the tabsGrid-template-columns: auto-fit... but what of grid-template-rows?In this example, I happily used grid-template-columns: repeat(auto-fit, etc); these buttons are actuangular project problemI have two component hero section and nav-bar component.i want to set a comman background for both o