Questions tagged [scss-mixins]

Mixins allow you to define styles that can be re-used throughout your stylesheet

One of the most important usages of mixins is to avoid using non-semantic classes like .float-left.

Mixins are defined using the @mixin at-rule, which is written

@mixin <name> { ... } or @mixin name(<arguments...>) { ... }

A mixin’s name can be any Sass identifier, and it can contain any statement other than top-level statements.

Example of mixin in SCSS:

@mixin reset-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

@mixin horizontal-list {
  @include reset-list;

  li {
    display: inline-block;
    margin: {
      left: -2px;
      right: 2em;
    }
  }
}

nav ul {
  @include horizontal-list;
}

Result in CSS:

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
nav ul li {
  display: inline-block;
  margin-left: -2px;
  margin-right: 2em;
}
655 questions
-1
votes
1 answer

How can i change sass variable values when parent html-tag is `nav`?

Variables: $inverse-icon-button-background: #ddd !default; $inverse-icon-button-color: $bbb !default; $inverse-icon-button-hover-background: $ccc !default; $inverse-icon-button-hover-color: #000 !default; I'd like to change…
Cem Firat
  • 390
  • 2
  • 21
-1
votes
1 answer

sass bootstrap4 is not getting applied to my html file

m newbie to sass i have this html file to which i hve applied sass hhhhhhhhhhhhhhhhhhhhhhhhhhllllllllllllll and my…
Tested
  • 761
  • 4
  • 16
  • 38
-1
votes
1 answer

How can I get responsive classes with this mixin

My sass file looks like this when I use my mixin: $viewports: 25 50 75 100; @each $viewport in $viewports { .vh-#{$viewport} { height: #{$viewport}vh; } } .vh-25 { height: 25vh; } ... But I want that class and the class with the @sm,…
Goestav
  • 37
  • 1
  • 7
-1
votes
1 answer

Change CSS RGBA color based on main template color in SASS

I am writing HTML template with SASS. What I want to achieve is whenever my client change the main template color, the box-shadow color will also be changed and match with the template color. I have a main template color variable and box shadow…
Poe Eain
  • 73
  • 1
  • 9
-2
votes
1 answer

Error when adding styles to a view in odoo 16

I've created a module and it works fine, but when I add styles to it I can't install it.HERE I COPY THE SCREENSHOTS TO HELP ME RESOLVE.Image del manifest.py Part of code xml Directory of my files error Based on the error message, it seems that the…
-2
votes
1 answer
-2
votes
2 answers

My Side navbar doesn't collapse after page reload

I have a side navbar using HTML, SCSS and js. When I click reload, it goes to uncollapse state. HTML
-2
votes
1 answer

How to understand the &-sign in Less/SCSS?

I'm trying to understand the & sign in Less. According to lesscss.org, the & represents the current selector parent. So what does it mean in the instance below? The css for the container class is obvious. But what does the &-footer, .CancelButton…
Kasper Hansen
  • 6,307
  • 21
  • 70
  • 106
-3
votes
3 answers

Background color for UL element didn't work

I want to highlight every 2 rows alternately like the image below but I can't make it work using UL element. Here is code https://jsfiddle.net/
lady coder
  • 13
  • 2
1 2 3
43
44