Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

global box-sizing: border-box; #52

Open
snowdream opened this issue Oct 2, 2021 · 2 comments
Open

global box-sizing: border-box; #52

snowdream opened this issue Oct 2, 2021 · 2 comments

Comments

@snowdream
Copy link

snowdream commented Oct 2, 2021

should we use:

html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}

better than

/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}
@Flo2ent
Copy link

Flo2ent commented Oct 21, 2021

Nope.
I had issues with inherit.

For example, in this code:
(HTML)

<main>
  <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam, consectetur? Tenetur facilis vitae doloribus minima.
  </p>
</main>

(CSS)

html {
  box-sizing: border-box;
}


*,
::before,
::after {
  box-sizing: inherit;
}


main {
  /*
   Set a 65ch maximum inline size for readability.
   We must apply this to the content box.
  */
  box-sizing: content-box;
  max-inline-size: 65ch;
  margin-inline: auto;
  padding-inline: 1.6rem;
}

...the issue we encounter is that the <p> (or whatever inside <main>) inherits the content-box declaration.

@snowdream
Copy link
Author

We want to set "box-sizing: border-box;" as the root box-sizing, and "box-sizing: inherit" as the default box-sizing.

If you set a container with "box-sizing: content-box;", you should set the box-sizing of the components in the container yourself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants