1

Hi amazing stack overflow people.

I'm trying to make a re-usable style base for my projects in SCSS.

The idea is pretty much Boostrap but without the Boostrap.

So in a HTML element I would add a style class, something to define how the elements flex/grid/ect should be used like this:

<div class="flex-r-between">

This is where:

flex = display: flex;
r = flex-direction: row;
between = justify-content: space-between; 

So in my SCSS I have wrote a rule like this:

.flex{
  display: flex;
  &-{
    &r-{
      display: row;
      &even{
        justify-content: space-evenly;
      }
      &between{
        justify-content: space-between;
      }
    }
  }
}

BUT (here is the issue) :

this convention does not apply each of the styles like a check, it just adds the LAST valid css rule - in this case:

justify-content: space-between;

enter image description here

Now I totally get that there is probably a very good reason for this...

I am wondering if there is another way to write this SCSS so that at each of the points that the CSS is met i.e.

class="flex" << display flex is added 
class="flex-r" << display flex + flex-direction row is added 
ect ect

A final note (yes sorry I know this getting long as it is):

I'm trying to avoid spacing these styles out so they can be more concise.

i.e.

Is this possible or is the above the only way to approach this

Wally
  • 705
  • 1
  • 9
  • 24
  • 1
    Does this answer your question? [Is it possible to include the parent properties in an extended Sass class?](https://stackoverflow.com/questions/26483186/is-it-possible-to-include-the-parent-properties-in-an-extended-sass-class) – disinfor Jun 07 '21 at 15:21
  • Awesome - didn't think about using the @exstends - but yeah that would solve it – Wally Jun 07 '21 at 15:43

0 Answers0