Breakpointer

Arguments

NameTypeDescription
$selectorstring

Help you to target one specific selector. Default it is targeting the ::before pseudo-element of the <body> tag.

* You can pass a declaration block to change its appearance cosmetically.

Examples

Call the mixin at the root level of your style sheet without passing any argument.

@include breakpointer;
//CSS Output
@media (min-width: 0) {
  body::before {
    content: "xsmall";
  }
}
@media (min-width: 576px) {
  body::before {
    content: "small";
  }
}
@media (min-width: 768px) {
  body::before {
    content: "medium";
  }
}
@media (min-width: 992px) {
  body::before {
    content: "large";
  }
}
@media (min-width: 1200px) {
  body::before {
    content: "xlarge";
  }
}

You can pass a CSS declaration block to customize the looking (as I did when I was developing the Gerillass’ site itself).

@include breakpointer {
  position: fixed;
  top: 0;
  right: 0;
  color: white;
  padding: 5px 10px;
  z-index: 10;
}

You can change the appearance as you like.

Well, good news! You can call the Breakpointer Sass mixin in a selector if you wish.

.element {
  @include breakpointer();
}
//CSS Output
@media (min-width: 0) {
  .element::before {
    content: "xsmall";
  }
}
@media (min-width: 576px) {
  .element::before {
    content: "small";
  }
}
@media (min-width: 768px) {
  .element::before {
    content: "medium";
  }
}
@media (min-width: 992px) {
  .element::before {
    content: "large";
  }
}
@media (min-width: 1200px) {
  .element::before {
    content: "xlarge";
  }
}
Important: This mixin is for development mode only. So don’t forget to comment out or remove the code before going any further for the production.