MotivationInstallDocsCustomize
MotivationInstallDocsCustomize
  • Overview
  • Important! Purge!
  • Getting Started
    • Colors and Pseudo Classes
      • Colors
        • Color Shades

        • Psuedo Classes

      • Classes with Colors
        • Text Color

        • Background Color

        • Border Color

        • Outline Color

        • Text Decoration

        • Selection

      • Transitions
        • Transition Classes

        • With Pseudo Classes

      • Additional Classes
        • Font Size

        • Font Family

        • Font Weight

        • Text Decoration & Style

        • Border Width & Style

        • Outline Width & Style

    • Dark Mode
      • With JS

      • No JS

      • Grid
        • Class Definitions

        • Responsive Examples

        • Responsive Examples
          • Breakpoints

          • Max Breakpoints

          • Examples

          • Margin
            • Classes

            • Examples

          • Padding
            • Classes

            • Examples

          • Border Width
            • Classes

            • Examples

          • Outline Width
            • Classes

            • Outline Offset

            • Examples

          • Width
            • Rem Values

            • Percantage Values

            • Screen relative Values

            • XS - XL

          • Height
            • Rem Values

            • Percantage Values

            • Screen relative Values

            • XS - XL

          • Display
          • Flex
            • Flex Direction

            • Flex Wrap

            • Shrink & Grow

            • Justify Content

            • Align Content

            • Align Items

            • Align Self

            • Not Included

          • Text/Font
            • Font Size

            • Line Height

            • Letter Spacing

          • Position
            • Top Left Right & Bottom

          • Overflow
            • Overflow x & y

          • Box Sizing
        • Box-Shadow
          • Size

          • Color

          • Respoinsive

          • Psuedo States

          • Other Utilities
            • Text/Font
              • Align

              • Transform

              • Indent

              • Wrap

              • Font Family

              • Font Weight

              • Font Style

              • Text Decoration

              • Decoration Thickness

            • Border
              • Directional Style

            • Outline Style
            • Cursor
            • Opacity
            • Visibility
            • z-Index

          Simple Scss Utilities


          Display: Flex

          How to use the flex classes

          Display flex is the infinately useful layout tool and I tried to include every utility class I would commonly use in a project. I manily stick to flexbox myself, so I don't include the css-grid classes, although I did include a very simple col-based grid system. If you need css-grid, it's a complex enough and unique enough set of styling rules to me it just makes sense to maybe write it in custom scss instead of trying to learn a seperate set of framework rules on top of it.

          Flex Direction

          First up is flex direction. Here are the classes:

          ClassCSS rule
          .flex-rowflex-direction: row;
          .flex-colflex-direction: column;
          .flex-row-reverseflex-direction: row-reverse;
          .flex-col-reverseflex-direction: column-reverse;

          Example

          For a demonstration, here are two sets of flex elements, one with the flex-row class, and one with the flex-col class. The grid system covered (here)[/docs/grid/] is also based on flex, so I just use that to lay these out side by side. It's not to be confused with the flexbox-related css grid (not included in this framework).

          Notice in the html that I use the max-scr: prefix to switch to the row-reverse and col-reverse classes on widths below the scr breakpoint (by default 1024 px):

          .max-scr:flex-row-reverse

          .flex-row

          .max-scr:flex-col-reverse

          .flex-col

          1
          2
          3
          4
          1
          2
          3
          4
          HTML
          <div class="row gap-md text-white pr-lg">
          <div class="col-6 br-sm border-dotted border-default">
          <div class="display-flex flex-row max-scr:flex-row-reverse bg-background-dkr">
          <div class="w-3 h-3 center bg-blue m-sm">1</div>
          <div class="w-3 h-3 center bg-blue m-sm">2</div>
          <div class="w-3 h-3 center bg-blue m-sm">3</div>
          <div class="w-3 h-3 center bg-blue m-sm">4</div>
          </div>
          </div>
          <div class="col-6">
          <div class="display-flex flex-col max-scr:flex-col-reverse bg-background-dkr">
          <div class="w-3 h-3 center bg-blue m-sm">1</div>
          <div class="w-3 h-3 center bg-blue m-sm">2</div>
          <div class="w-3 h-3 center bg-blue m-sm">3</div>
          <div class="w-3 h-3 center bg-blue m-sm">4</div>
          </div>
          </div>
          </div>

          Flex Wrap

          The flex wrap classes are:

          ClassCSS rule
          .flex-wrapflex-wrap: wrap;
          .flex-nowrapflex-wrap: nowrap;
          .flex-wrap-reverseflex-wrap: wrap-reverse;

          Example

          Expanding on the previous example, I will set a fixed height to the column container and compare no-wrap to the wrap classes. Like before, I will use the .max-scr breakpoint to switch between the wrap classes, so below 1024px it will be flex-wrap-reverse:

          flex-wrap: nowrap; (default)

          max-scr:flex-wrap-reverse

          .flex-wrap

          1
          2
          3
          4
          5
          1
          2
          3
          4
          5

          Here's the HTML:

          HTML
          <div class="row gap-md text-white pr-lg mb-lg">
          <div class="col-6 br-sm border-dotted border-default">
          <div class="display-flex flex-col bg-background-dkr h-10">
          <div class="w-3 h-3 center bg-blue m-sm">1</div>
          <div class="w-3 h-3 center bg-blue m-sm">2</div>
          <div class="w-3 h-3 center bg-blue m-sm">3</div>
          <div class="w-3 h-3 center bg-blue m-sm">4</div>
          <div class="w-3 h-3 center bg-blue m-sm">5</div>
          </div>
          </div>
          <div class="col-6">
          <div class="display-flex flex-col flex-wrap max-scr:flex-wrap-reverse bg-background-dkr h-10">
          <div class="w-3 h-3 center bg-blue m-sm">1</div>
          <div class="w-3 h-3 center bg-blue m-sm">2</div>
          <div class="w-3 h-3 center bg-blue m-sm">3</div>
          <div class="w-3 h-3 center bg-blue m-sm">4</div>
          <div class="w-3 h-3 center bg-blue m-sm">5</div>
          </div>
          </div>
          </div>

          Flex Shrink and Flex Grow

          Flex shrink and grow are useful to know for layout. There's only two utility classes for each by default:

          ClassCSS rule
          .shrink-0flex-shrink: 0;
          .shrink-1flex-shrink: 1;
          .grow-0flex-grow: 0;
          .grow-1flex-grow: 1;

          Example

          Let's continue with a similar example of numbered divs in a flex-col container:

          Nowrap and shrink-0 on elements. The numbered divs break out of the container instead of shrinking:

          Flex-wrap is set to 'wrap' and divs 4 and 5 have been given a class of .grow-1 so they take up the extra leftover space in their columns:

          1
          2
          3
          4
          1
          2
          3
          4
          5

          The Html for this example:

          HTML
          <div class="h-20">
          <div class="row gap-md text-white pr-lg mb-lg">
          <div class="col-6 br-sm border-dotted border-default">
          <div class="display-flex flex-col bg-background-dkr h-12">
          <div class="w-3 h-3 center bg-blue m-sm shrink-0">1</div>
          <div class="w-3 h-3 center bg-blue m-sm shrink-0">2</div>
          <div class="w-3 h-3 center bg-blue m-sm shrink-0">3</div>
          <div class="w-3 h-3 center bg-blue m-sm shrink-0">4</div>
          </div>
          </div>
          <div class="col-6">
          <div class="display-flex flex-col flex-wrap max-scr:flex-wrap-reverse bg-background-dkr h-10">
          <div class="w-3 h-3 center bg-blue m-sm">1</div>
          <div class="w-3 h-3 center bg-blue m-sm">2</div>
          <div class="w-3 h-3 center bg-blue m-sm">3</div>
          <div class="w-3 h-3 center bg-blue m-sm grow-1">4</div>
          <div class="w-3 h-3 center bg-blue m-sm grow-1">5</div>
          </div>
          </div>
          </div>
          </div>

          Justify Content

          Justify content is simply prefixed with justify

          ClassCSS rule
          .justify-initialjustify-content: initial;
          .justify-inheritjustify-content: inherit;
          .justify-startjustify-content: flex-start;
          .justify-endjustify-content: flex-end;
          .justify-centerjustify-content: center;
          .justify-aroundjustify-content: space-around;
          .justify-betweenjustify-content: space-between;
          .justify-evenlyjustify-content: space-evenly;
          .justify-stretchjustify-content: stretch;

          Example

          Each section below is flex-row and flex-wrap and has a different justfy property. Note: the itmes for justify-stretch have a grow-1 class, (otherwise justify-items: stretch; has no effect)

          justify-normal

          1
          2
          3
          4
          5

          justify-start

          1
          2
          3
          4
          5

          justify-end

          1
          2
          3
          4
          5

          justify-center

          1
          2
          3
          4
          5

          justify-around

          1
          2
          3
          4
          5

          justify-between

          1
          2
          3
          4
          5

          justify-evenly

          1
          2
          3
          4
          5

          justify-stretch

          1
          2
          3
          4
          5

          To avoid a long block of html, I've only included two of the above examples here since basically each block only differes by a single class (except justify-stretch which also needs a grow-1 class on the inner divs):

          HTML
          <!-- justify-center -->
          <div class="display-flex flex-wrap justify-center bg-background-dkr text-white">
          <div class="w-2 h-2 center bg-blue m-sm">1</div>
          <div class="w-2 h-2 center bg-blue m-sm">2</div>
          <div class="w-2 h-2 center bg-blue m-sm">3</div>
          <div class="w-2 h-2 center bg-blue m-sm">4</div>
          <div class="w-2 h-2 center bg-blue m-sm">5</div>
          </div>
          <!-- justify-stretch -->
          <div class="display-flex flex-wrap justify-stretch bg-background-dkr text-white">
          <div class="w-2 h-2 center bg-blue m-sm grow-1">1</div>
          <div class="w-2 h-2 center bg-blue m-sm grow-1">2</div>
          <div class="w-2 h-2 center bg-blue m-sm grow-1">3</div>
          <div class="w-2 h-2 center bg-blue m-sm grow-1">4</div>
          <div class="w-2 h-2 center bg-blue m-sm grow-1">5</div>
          </div>

          Align Content

          Although justify-content is prefixed with just justify (kinda becuase that's how I'm used to using it from tailwind but also because it tends to be the most useful alignment class in practice in my experience), align-content and align-tiems also have useful applicatoins in flexbox.. and they are prefixed sith content and items prefixes.

          Align content is really kind of analagous to justify-content, exept on the perpendicular axis, at least in my mind. So here's the content classes:

          ClassCSS rule
          .content-initialalign-content: initial;
          .content-inheritalign-content: inherit;
          .content-startalign-content: flex-start;
          .content-endalign-content: flex-end;
          .content-centeralign-content: center;
          .content-aroundalign-content: space-around;
          .content-betweenalign-content: space-between;
          .content-evenlyalign-content: space-evenly;
          .content-stretchalign-content: stretch;

          To make these examples more illustrative, I increased the heights of the container:

          content-initial

          1
          2
          3
          4
          5
          6

          content-start

          1
          2
          3
          4
          5
          6

          content-end

          1
          2
          3
          4
          5
          6

          content-center

          1
          2
          3
          4
          5
          6

          content-around

          1
          2
          3
          4
          5
          6

          content-between

          1
          2
          3
          4
          5
          6

          content-evenly

          1
          2
          3
          4
          5
          6

          content-stretch

          1
          2
          3
          4
          5
          6

          To avoid a huge block, I just include two of the above examples here. Notice that for content-stretch to work, the elements can't have an explicit height:

          HTML
          <!-- content-end -->
          <div class="display-flex flex-wrap content-end bg-background-dkr text-white h-16">
          <div class="w-3 h-3 center bg-blue m-sm ">1</div>
          <div class="w-3 h-4 center bg-blue m-sm ">2</div>
          <div class="w-3 h-5 center bg-blue m-sm ">3</div>
          <div class="w-3 h-3 center bg-blue m-sm ">4</div>
          <div class="w-3 h-4 center bg-blue m-sm ">5</div>
          <div class="w-3 h-5 center bg-blue m-sm ">6</div>
          </div>
          <!-- content-stretch -->
          <div class="display-flex flex-wrap content-stretch bg-background-dkr text-white h-16">
          <div class="w-2 center bg-blue m-sm">1</div>
          <div class="w-2 center bg-blue m-sm">2</div>
          <div class="w-2 center bg-blue m-sm">3</div>
          <div class="w-2 center bg-blue m-sm">4</div>
          <div class="w-2 center bg-blue m-sm">5</div>
          <div class="w-2 center bg-blue m-sm">6</div>
          </div>

          Align Items

          Align items classes are prefixed with items as I've mentioned above:

          ClassCSS rule
          .items-normalalign-items: normal;
          .items-startalign-items: flex-start;
          .items-endalign-items: flex-end;
          .items-centeralign-items: center;
          .items-stretchalign-items: stretch;
          .items-baselinealign-items: baseline;
          .items-initialalign-items: initial;
          .items-inheritalign-items: inherit;

          Example

          Align-items has a bit more application in flexbox than justify-items, at least I know that align-items: flex-end; is something I've had to google at least a few times before haha.

          Since these examples are flex-row and in this case align-items works on the horizontal axis (the "cross-axis", aka the opposite of flex direction), I've increased the height of the containers as well as varied the heights of the items to more clearly show the effects. I've also left out normal and initial because they don't do much that items-start or items-inherit doesn't do in this paritcular case. The difference betwee .items-center and .items-basline is subtle, but it's there haha. Also note for items-stretch to work, elements in this case can't have an explicit defined height like with content-stretch:

          items-start

          1
          2
          3
          4
          5
          6

          items-end

          1
          2
          3
          4
          5
          6

          items-center

          1
          2
          3
          4
          5
          6

          items-baseline

          1
          2
          3
          4
          5
          6

          items-stretch

          1
          2
          3
          4
          5
          6

          items-inherit

          1
          2
          3
          4
          5
          6

          Like above, to avoid a hefty block of HTML, I've only included the items-end and items-basline classes here:

          HTML
          <!-- items-end -->
          <div class="display-flex flex-wrap items-end bg-background-dkr text-white h-16">
          <div class="w-3 h-3 center bg-blue m-sm ">1</div>
          <div class="w-3 h-4 center bg-blue m-sm ">2</div>
          <div class="w-3 h-5 center bg-blue m-sm ">3</div>
          <div class="w-3 h-3 center bg-blue m-sm ">4</div>
          <div class="w-3 h-4 center bg-blue m-sm ">5</div>
          <div class="w-3 h-5 center bg-blue m-sm ">6</div>
          </div>
          <!-- items-stretch -->
          <div class="display-flex flex-wrap items-stretch bg-background-dkr text-white h-16">
          <div class="w-3 center bg-blue m-sm ">1</div>
          <div class="w-3 center bg-blue m-sm ">2</div>
          <div class="w-3 center bg-blue m-sm ">3</div>
          <div class="w-3 center bg-blue m-sm ">4</div>
          <div class="w-3 center bg-blue m-sm ">5</div>
          <div class="w-3 center bg-blue m-sm ">6</div>
          </div>

          Align Self

          Phew! The last remaining flexbox utility class to cover is align-self.

          ClassCSS rule
          .align-self-autoalign-self: normal;
          .align-self-startalign-self: flex-start;
          .align-self-endalign-self: flex-end;
          .align-self-centeralign-self: center;
          .align-self-stretchalign-self: stretch;
          .align-self-baselinealign-self: baseline;

          Example:

          All these classes have flex-row. However, since alignment happens on the cross axis, it affects the vertical position. Note that the align-self-stretch class only has an effect if it's missing an explicity defined height.

          align-self-start

          align-self-end

          align-self-center

          align-self-stretch

          align-self-baseline

          The HTML is pretty straight forward for these:

          HTML
          <div class="display-flex justify-around mb-2xl">
          <div class="display-flex flex-row bg-background-dkr border-md border-dashed h-12">
          <div class="h-4 w-4 p-xs center text-white bg-blue sizing-border align-self-start">
          <p>align-self-start</p>
          </div>
          </div>
          <div class="display-flex flex-row bg-background-dkr border-md border-dashed h-12">
          <div class="h-4 w-4 p-xs center text-white bg-blue sizing-border align-self-end">
          <p>align-self-end</p>
          </div>
          </div>
          <div class="display-flex flex-row bg-background-dkr border-md border-dashed h-12">
          <div class="h-4 w-4 p-xs center text-white bg-blue sizing-border align-self-center">
          <p>align-self-center</p>
          </div>
          </div>
          <div class="display-flex flex-row bg-background-dkr border-md border-dashed h-12">
          <div class="w-4 p-xs center text-white bg-blue sizing-border align-self-stretch">
          <p>align-self-stretch</p>
          </div>
          </div>
          <div class="display-flex flex-row bg-background-dkr border-md border-dashed h-12">
          <div class="w-4 p-xs center text-white bg-blue sizing-border align-self-baseline">
          <p>align-self-baseline</p>
          </div>
          </div>
          </div>

          Not Included

          I don't include css-grid with this framework, although I did include a very simple col-based grid system. Actual CSS-Grid seems like a specific and complex enough task that it just makes more sense to me to use custom SCSS rather than learning a framework's way of handling that. It doesent seem any more convinent to use a framework, in other words, and because I'm mostly making this for myself (but doucmenting it in case someone else finds it interesting) I don't mind saving myself a lot of work including it for very little benefit!

          As such, these categories:

          • justify-items
          • justify-self

          also don't have untility classes, since those are grid-related.

          But anyway, that about covers the flexbox utilities. Happy Coding!

          © 2025 Simple Scss Utilities