Add-ons have box-sizing: border-box by default?!

Today I totally got surprised, because I found out that you set box-sizing: border-box.

This actually resulted in that odd behaviour for me:

I just wanted a fixed height/width for the SVG icon, but because browsers can scale SVGs and I had to use a padding instead of a margin (for hover/background-color effects) the whole box-sizing thing actually made my SVG icon smaller (and I had no idea why)…

So yes, I understand this is maybe useful, but as the same just linked article says:

You might think of it this way: with box-sizing: border-box the padding and border press their way inside the box rather than expand the box.

Ugh, yeah… and this can affect the inner content of your element.

Also, paddings can just be totally ignored when you have an auto width/height as the padding is just also automatically calculated into that size.
That is also not very obvious to devs (especially when they don’t know box-sizing is being applied :neutral_face:).

But, yeah, when one finally get’s out what is happen, it is obvious. You ship that thing out-of-the-box:
grafik


However, one thing you can do: Please make add-on devs aware that this is used – as this is a fundamental design/CSS (defaults) change for web extensions compared to websites (as the default there is content-box) and one may not notice it immediately (I did not, at least…). It is really bad when one has to discover this though some curious bug or inconsistent behaviour or so…

1 Like

Do you have browser_style enabled? Because this seems like a thing that could happen with that.

Yes, I have, but such a drastic change is not documented. The other changes only seem to be some minor differences – or, as it is the case for a textarea or so, even need to be applied manually with a class.
And, BTW, for options pages “browser-style” is also actually enabled by default.

1 Like

There are other major changes like user-select being disabled. But yeah, this is a leak of how the current style sheets work and should not affect arbitrary elements of yours.

I’m nobody official, but I added it to these three pages (anyone with an MDN login can edit):

Being enabled by default was noted in the article manifest.json/options_ui. It could be added elsewhere; you can add it where you think it makes sense.

1 Like