That’s why I prefer to use UI and JS libraries that are already tested and work consistently across browsers. It’s easier to reuse libraries across projects instead of reinventing the wheel, and spending time chasing down browser inconsistencies.
We often set ourselves up for failure by using JS APIs that don’t work across browsers, or hand rolling UI/CSS for each project.
Using a good library is not enough. For a simple example, try setting “height: 100vh;” on the body, and then open the page on an iPhone. You may be surprised that the height of the body does not fit into the screen and a scroll appears (I was, when I learnt about it). Similarly, there are many small differences that exist between Desktop <> Mobile or Chrome <> Safari. Sometimes the differences are significant enough to make your page appear completely broken.
Instead of writing custom CSS you could use or develop a UI library that targets browsers consistently, and use that.