Useful Sass (SCSS) media query mixins for Bootstrap (and everything else) (glennmccomb.com)
over 5 years ago from Glenn McComb, Freelance web designer and front-end dev
over 5 years ago from Glenn McComb, Freelance web designer and front-end dev
Well written and presented, but we do have many of these mixins and the Sass map in our source code with v4 :). You can loop over $grid-breakpoints
and modify, add, or remove map values. You can use the breakpoint-up
, breakpoint-down
, breakpoint-between
, breakpoint-next
, etc to craft some crazy cool responsive CSS with our provided mixins.
Check out the v4 source at https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_grid-framework.scss.
Thanks Mark, wow those are awesome I hadn't dug right in to v4 - that is some very neat Sass. To be honest I generally include bootstrap.css on its own (compiled via a separate Sass build process). I did this previously because I found the v3 Sass build process took a fair while considering I rarely changed it.
I haven't used v4 in production due to old browser support requirements (yes we have those kinds of clients) but I did find the grid to be highly awesome so I've used that in isolation in my personal projects.
Cheers for the reply!
Right on! Let me know what you think of v4 once you dig into it :).
This is a very good approach for SCSS media query mixins. Nice work! I’ll try this out on my next project
Thanks Kevin!
What about just nesting media:
.element { background-color: pink; @include mw(small) { background-color: red; } }
Designer News
Where the design community meets.
Designer News is a large, global community of people working or interested in design and technology.
Have feedback?
Login to Comment
You'll need to log in before you can leave a comment.
LoginRegister Today
New accounts can leave comments immediately, and gain full permissions after one week.
Register now