Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active July 13, 2019 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/d6484c2cf5c940d1aef17bea7a82e5d9 to your computer and use it in GitHub Desktop.
Save tomhodgins/d6484c2cf5c940d1aef17bea7a82e5d9 to your computer and use it in GitHub Desktop.
/*
<breakpoints-list> := <custom-ident> <breakpoints-func> [ ',' <custom-ident> <breakpoints-func> ]*
<breakpoints-func> := '--breakpoints(' <breakpoint>* <custom-ident> [ <breakpoint> <custom-ident>]* ')'
<breakpoint> := <number> | 'portrait' | 'square' | 'landscape' …etc
*/
/* Using named breakpoints for describing element query breakpoints for width */
div {
--observe-width: --breakpoints(narrow 500 wide);
}
/* Describing named breakpoints for more than one condition */
div {
--observe-width: --breakpoints(narrow 500 wide);
--observe-height: --breakpoints(short 500 tall);
}
/* Using a breakpoints list to describe breakpoints for more than condition */
div {
--observe:
width --breakpoints(narrow 500 wide),
height --breakpoints(short 500 tall)
}
/* Just for fun, here are different formattings of the same information: */
/* single line, individual conditions */
div {
--observe-width: --breakpoints(0 narrow 500 wide);
--observe-height: --breakpoints(0 short 500 tall);
}
/* multiline, individual conditions */
div {
--observe-width: --breakpoints(
0 narrow
500 wide
);
--observe-height: --breakpoints(
0 short
500 tall
);
}
/* single-line, multiple conditions */
div {
--observe: width --breakpoints(narrow 500 wide), height --breakpoints(short 500 tall)
}
/* multiline, multiple conditions */
div {
--observe:
width --breakpoints(narrow 500 wide),
height --breakpoints(short 500 tall)
}
/* another multiline, multiple conditions, having fun with the visual placement of terms */
div {
--observe:
width --breakpoints(
/* ← - → */
narrow 500 wide
),
height --breakpoints(
short /* ↑ */
500 /* | */
tall /* ↓ */
)
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment