Conditional CSS Code
See original GitHub issueHow about having something like conditional css code depending upon variable
@has_theme_support: true;
.awesome-class {
width: 100px;
height: 200px;
margin: 0 auto;
/* Adds theme support if @has_theme_support is 'true'; */
if( @has_theme_support ){
background: green;
color: yellow;
}
}
Issue Analytics
- State:
- Created 10 years ago
- Reactions:6
- Comments:60 (33 by maintainers)
Top Results From Across the Web
CSS Conditional Rules - CSS: Cascading Style Sheets | MDN
CSS Conditional Rules is a CSS module that allows to define a set of rules that will only apply based on the capabilities...
Read more >Can you use if/else conditions in CSS? - Stack Overflow
CSS has a feature: Conditional Rules. This feature of CSS is applied based on a specific condition. Conditional Rules are: @supports.
Read more >if/else condition in CSS - GeeksforGeeks
Given an HTML file and we need to apply using if-else conditions in CSS. No, We can not use if-else conditions in CSS...
Read more >CSS Conditional Rules Module Level 3 - W3C
Each conditional group rule has a condition, which at any time evaluates to true or false. When the condition is true, CSS processors...
Read more >Use CSS to change the style of each row depending on the ...
Templates help display your data. But if your template requires rules to be applied to specific CSS selectors, using Conditional Display is the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes I know that but if we are writing huge LESS we have to write and manage hundreds of .mixins I don’t think mixin solves this issue. Even mixins will get lot of power with this feature. Less CSS almost have all the feature that some programming language has then why not this ?
I think ‘sass’ is better than less. It already has if-else. It is really hard and many lines of coding the less. When works but it doesn’t full fill the need. Additionally we can make loops in less but language should have it’s own feature.