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.

Suggestion: add classes at breakpoints

See original GitHub issue

In many cases I don’t want to create multiple elements for large/small layouts, I simply need a different css class applied. It would be nice to have a directive that would apply a css class based on the screen size (versus show/hiding the element). For example:

<p *sm-class="my-small-class" *lg-class="my-big-class">example</p>

When the window is small, .my-small-class is applied to the element, and when the screen is large, .my-big-class would be applied to the element.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ackushiwcommented, Jun 19, 2016

I’ve just come across this repository so forgive me if this is already a feature, but what about injecting a service into components, that way we can use the ngClass directive, and even trigger functions on changes to orientation etc.

1reaction
no-morecommented, Jun 14, 2016

Hi,

That’s sound a good idea, but maybe instead of changing the class on the element, wouldn’t it be easier if there was a specific class on the body like “responsive-breakpoint-lg”. We could also add other devices information. In the application you could then use the class as a media query to handle different layout according to the screen size:

body.responsive-breakpoint-lg .myClass{/*layout for lg, same as .my-big-class*/}
body.responsive-breakpoint-sm .myClass{/*layout for sm, same as .my-small-class*/}

The main advantages of this :

  • no need to redefine breakpoint size in the css
  • can handle other type of information (device …)
  • only one entry point, reduce number of watchers and directives to implements!!!

Would this meet your requirements ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way to set breakpoints on all methods of a class?
You can follow the steps below: Run -> View breakpoints -> Add -> Java Method Breakpoints. Class pattern -> full reference of your...
Read more >
The 100% correct way to do CSS breakpoints - freeCodeCamp
So I have three suggestions: Get your breakpoints right; Name your ranges sensibly; Be declarative. Tip #1: Get your breakpoints right. So what ......
Read more >
Style across breakpoints | Webflow University
Add and change styles, determine style inheritance, and clear styles using breakpoints in the Designer.
Read more >
CSS · Bootstrap
Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller...
Read more >
Breakpoints for Responsive Web Design - BrowserStack
What is a Breakpoint in Responsive Design? · When Should a Standard Responsive Breakpoint be Added? · Best Practices for Adding Standard ...
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