Really Simple Media Queries with Sass
Breakpoint makes writing media queries in Sass super simple. Create a variable using a simplified syntax based on most commonly used media queries, then call it using the breakpoint
mixin. Breakpoint handles all of the heavy lifting, from writing the media query itself, to handling cross-browser compatibility issues, so you can focus on what's important: making sure your website looks its best.
Breakpoint also allows you to get the context of your media queries from your code, allowing you to write dynamic mixins based on their media query context.
If you'd prefer the semantic awesomeness of string names to identify your queries as opposed to variables, or want to dynamically generate media queries, the Respond-To syntax is now included in Breakpoint core!
It is important to note that due to limitations within the Sass language itself, which themselves stem from some potentially unexpected cascading from doing so, Breakpoint is unable to concat like media queries into a single media query. This means they will be spread out throughout your CSS. This is unfortunate, yes, but currently unavoidable. That being said, once Sass Issue #241: Seperate Media/Browser Specific Markup to Separate Style Sheet hits, be sure we're going to take full advantage of it.
Breakpoint Wiki
Full documentation is available on theGetting Help with Breakpoint
- For help with Breakpoint, please ask a question on Stack Overflow tagged with "breakpoint-sass".
- To file an issue with Breakpoint, be it a feature request or a bug report, please use our Issue Queue.
- Each Separate Bug Report or Feature Request Must Have Its Own Issue
- Search in both active issues and closed issues before filing your own. If one already exists, please respond there.
- If you are in IRC, the maintainers and many fellow users tend to hang out in the #sass and #compass rooms on irc.freenode.net. Asking in there may get you a quick answer to your question, but we still encourage you to file your inquiry in the appropriate place above to
Contributing to Breakpoint
We love contributors! Yes we do! If you would like to contribute to Breakpoint, please follow the Contributing Guidelines
Awesome Things Built With Breakpoint
Breakpoint is designed to be a Media Query engine to power everything from design tweaks to media query contexts to full media query fallbacks. But we also know that our users will build awesome thing with these tools. Build a Breakpoint powered mixin for new media query semantics? We want to hear about it! Build something cool with Context? Let us know! If you would like to add your Awesome Thing to the list, please issue a Pull Request to add it!
- Singularity - Semantic Grid System
- Breakpoint Slicer - Quick and efficient syntax for Min/Max Width media queries
License
Licensed under MIT/GPL.
GPL2 license: http://www.gnu.org/licenses/gpl-2.0.html
MIT license: http://www.opensource.org/licenses/mit-license.php
Breakpoint Version 2
After some discussion and percolation I think we have the major features and workflow of Breakpoint 2.0 worked out.
Breakpoint 2
Breakpoint 2 will add full media query handling, including only, not, and or operators, along with making working with breakpoint variables simpler and more robust.
Example breakpoint variables:
Feature list types
500px
// default-feature-valuemin-height 500px
// feature valuewidth 20em 30em
// feature min-value max-valuescreen
// media-type'only' screen
// operator media-typeno-query '.nq'
// no-query-flag selectorAnd and Or operators
In V2, and operators will use the keyword
'and'
, while or operators will use a comma.Prefixed features
To be decided. Maybe keyword handling, maybe array handling, although both have unique complexity issues.
Combination of multiple breakpoint variables
The following should be possible:
Variable arguments
By switching to keywords and internal handling instead of separate arguments, we can use variable arguments in the mixin and streamline ux.
Context
Now that we are allowing or media queries, context will have to return a list, sorted from smallest to largest value.
Warnings
We should throw warnings on some possible user errors:
Thoughts, problems, suggestions? @Snugug, want to make a canonical v2 branch and divide some of these features to work on?
breakpoint-to-base-em() function doesn't convert ems
Since breakpoints happen in base ems, but layouts happen in local ems, this function should be able to convert em-values as well. That requires a font-size argument. This function is otherwise identical to Susy's. Why was the font-size conversion removed?
compile error
At the first run of breakpoint I'm getting the following error:
I'm compiling with Codekit with breakpoint installed as a partial.
Breakpoint without Compass
Anychance that someone could help with this issue here: http://stackoverflow.com/questions/24963153/breakpoint-in-rails-app about getting Breakpoint to work without Compass?
Thanks, Neil
No query stored in breakpoint variable
I have previously written my own mixins for breakpoints and had a similar solution for no query support where I would pass true or false to the mixin and that would decide whether or not that content was in included in the no-query/old-ie stylesheet.
I have got this mostly working with breakpoint, except there doesn't seem to be a way to store the $no-query variable in a breakpoint variable.
eg.
$gte-medium: 35em, all, true
That way I don't need to continuously write:
@include breakpoint($gte-medium, $no-query: true)
every time I have something at the medium breakpoint I can just write:
@include breakpoint($gte-medium)
It allows me to set all my breakpoints(with no query specificity) in my settings file incase I decide to change it or when I am working with other developers that don't know what styles should go to old ie etc they can just use the default breakpoint variables without worrying about it.
Is this possible at the moment? Am I missing something?
Thanks, Luke
Implement the ability to generate an IE only stylesheet
When adopting a mobile-first approach, it is important to provide desktop styles to old versions of IE that do not support media queries. This has previously been achieved without @media bubbling in Sass. Please read this article by Jake Archibald, in which he demonstrates a new method that allows the creation of an IE only stylesheet whilst simultaneously using @media bubbling.
This commit adopts this method, but rather than using the variable name of
$fix-mqs
, it instead uses$fix-breakpoint
. I'm not completely familiar with the ins and outs of the Breakpoint library, but I have tried my best to incorporate here.Breakpoint Get Context 2.x
Breakpoint Get Context for 2.x.x gets more complicated with the addition of built-in 'or' query support. As a developer, I'd like the following returned to me from a breakpoint get context query:
I would be okay with trailing falses no being present, but would like to see a companion function to make all lists the same length, padded with
false
. I would like this because I need to be able to have all of my lists the same length to programmatically work with them and ensure thator
s properly line up with their functionality.Query return without first argument
When writing
@include breakpoint(800px)
, breakpoint returns@media and (min-width: 800px)
I presume this may be a compiler issue, because I have used Breakpoint in another project where I was compiling with Codekit (and it worked). This time I’m compiling with Gulp (gulp-sass).
I have Sass 3.3.4 installed.
Thoughts?
Updated min/max, DX improvement to feature/value
Updated the min/max functionality to be able to be used with any valid value, not just min-width. Also added in handling for prefixing device-pixel-ratio media query. Also added ability for single feature/value pairs to be written with feature first or second. Finally, converted from Sass to SCSS.
Becomes
TODO: Need to be able to write min/max in either order, but that can be written off to API constraints.
Line 47 of app/public/bower/breakpoint-sass/_breakpoint.scss: Invalid CSS after "...ntext holder') ": expected "}", was "!global;"
Why am I getting this error?
line 47 looks like this:
full stack trace has been concatenated I'm afraid. might be able to get something. Is !global valid?
Remove compass dependency?
I see that Compass is not required for compiling breakpoint's CSS. https://github.com/Team-Sass/breakpoint/issues/46
Would it be acceptable to remove the gem dependency on Compass, using Compass::Frameworks.register if compass is available, falling back to Sass.load_paths? An example implementation is in bootstrap-sass: https://github.com/twbs/bootstrap-sass/blob/master/lib/bootstrap-sass.rb
Are Level 4 Media Queries supported???
Media Queries Level 4
@media (hover: none) { // look mom! i might be a touch device }
how would I write the query above in the current form?
when i do
@import breakpoint($phone) { }
and $phone: (hover none); or hover: 'none' or etc etc down the list, nothing is currently working....
can't override default variables
In Breakpoint 2.6 you changed die default variables from sass-variables to a sass-map called $breakpoint-settings. it is very difficult to override sass map variables (only with a roudtrip), see: https://getbaseweb.com/blog/2017/03/07/overriding-variable-maps-with-sass/ for example: $breakpoint-no-query-fallbacks: true; or $breakpoint-to-ems: true; is not possible, the documentation is wrong and depracated please switch back to normal sass variables or provide an other way to override the default variables
eyeglass usage notes
Hey, first up, this thing is awesome. Thank you guys for creating it.
Now, my question: could you could provide documentation for eyeglass usage somewhere, even something simple like what modularscale does:
(I'm just asking, because I spent 15-20 minutes poking around before I realized the
@import
name was just "breakpoint", not "breakpoint-sass".)Can media queries be grouped in css?
Already with this sass eg.:
compiles to css:
So - can it be grouped and compiled to:
It saves some css file size.
Installation for breakpoint doesn't work
I have followed the instructions for installing breakpoint only to get the following error when I try do do compass watch:
I also would like to use the alternate method of installing breakpoint using bower, but this line really should be fully written out rather than expecting everyone to understand what the heck it means:
What folder and where does add_import go?