Display
display decides how an element participates in layout: as a block, an inline
box, a flex container, a table part, or not at all. These are plain declarations
with no token to tune.
Classes
Section titled “Classes”| Class | display |
|---|---|
d-block |
block |
d-inline |
inline |
d-inline-block |
inline-block |
d-flex |
flex |
d-inline-flex |
inline-flex |
d-table |
table |
d-table-row |
table-row |
d-table-cell |
table-cell |
d-none |
none |
Compact aliases block, inline-block, inline, hidden, contents, and
flow-root are also available. contents and flow-root have no long spelling.
<div class="d-flex">…</div><div class="d-none d-md-block">Hidden below 768px</div>Responsive: d-sm-*, d-md-*, d-lg-*, d-xl-*, d-2xl-*.
These classes are in the separate responsive module: import
nightcss/utilities/responsive after the base bundle, or use
nightcss/full.
Showing and hiding
Section titled “Showing and hiding”The usual responsive pattern pairs d-none with a display class at a
breakpoint. Prefer it over visibility or opacity when the element should
leave the layout entirely:
<nav class="d-none d-lg-flex">Desktop navigation</nav><button class="d-lg-none">Menu</button>display: contents makes the element itself disappear from the box tree while
its children stay. Use it sparingly: it can strip semantics from things like
lists and buttons.
To lay out the children once the element is a flex container, see Flex and Alignment.