question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Media queries via (s)CSS

See original GitHub issue

Feature Request

What is the desired behavior?

Use media query via mixin in CSS

What is the use-case or motivation for the desired behavior?

From what i’ve read in the DOC if i want a style eg a button with different background color based on breakpoints i can only do something like

<button [ngClass.xs]="xs-button" [ngClass.xs]="md-button">HI!</button>

and in CSS

.xs-button {
  background-color: red;
}
.md-button {
  background-color: red;
}

This surely works but leads a lot of pollution in the markup, could you also export a mixins to do the below?

With CSS media query:

<button>HI!</button>


button {
  background-color: yellow;
  @include media-breakpoint(xs) {
     background-color: red;
   }
  @include media-breakpoint(md) {
    background-color: blue;
   }
}

I can of course crate a set of mixins to do the above but would be great if this would exposed by flex-layout matching configured breakpoints…

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:12
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
CaerusKarucommented, Dec 19, 2018

This feature will be included in today’s beta 22 release. To use, simply do the following in your SASS files:

@import '~@angular/flex-layout/mq';

// This works for all Flex Layout breakpoints
@include layout-bp(xs) {
	background-color: red;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Beginner's guide to media queries - Learn web development
The CSS Media Query gives you a way to apply CSS only when the browser and device environment matches a rule that you...
Read more >
Responsive Web Design Media Queries - W3Schools
Media query is a CSS technique introduced in CSS3. It uses the @media rule to include a block of CSS properties only if...
Read more >
A Complete Guide to CSS Media Queries
CSS Media queries are a way to target browser by certain characteristics, features, and user preferences, then apply styles based on those ...
Read more >
Media queries - web.dev
Adapt your designs to different screen sizes using CSS media queries. ... Designers can adjust their designs to accommodate users. The clearest example...
Read more >
The Best Way to Facilitate CSS Media Queries using SCSS ...
This article will explain how to create media queries using SCSS mixins. It will also show how to use the @include function to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found