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
5
votes
5 answers

ng build --base-href="/.../" --deploy-url="/.../" css background image not working

"@angular/core": "~8.0.0", scaffold angular 8 project with scss style option i have code for as mentioned below in component scss file background: url("/assets/images/vector-icon.png") no-repeat 25%; at the final buil using command ng build…
paras shah
  • 861
  • 2
  • 9
  • 23
5
votes
1 answer

How do I pass an HTML `data-` string attribute into a SCSS mixin via attr()?

I am trying to set up a color scheme in SCSS where I can have the following HTML:
...
I have a SCSS mixin defined as such: @function color($key: 'black') { @return map-get($colors, $key); } So, if I pass…
TerranRich
  • 1,263
  • 3
  • 20
  • 38
5
votes
3 answers

why inspections showing scss file instead of bootstrap.css?

When I do inspect element on one the row div it shows the element belongs to _grid.scss instead of bootstrap.css. And even the column in the row are not displaying correctly as it should be using bootstrap. Can someone clear this confusion? I don't…
safina
  • 212
  • 2
  • 13
5
votes
1 answer

CSS variable & SCSS mixin

I need to be able to use CSS variables because I need to have an hover effect (background-color) to be customizable by my VueJs app. But my CSS stylesheet should have a default value, which is stored in a nested SCSS map. (map-getter is a function…
user7663281
4
votes
1 answer

How to suppress SCSS linting for 1 line in VS Code?

I've written an SCSS mixin for creating a series of @container rules: @mixin form-grid-double-size-breakpoint($itemSize, $gapSize) { $breakPoint: $gapSize + $itemSize * 2; @container customcontainername (min-width: #{$breakPoint}) { //…
4
votes
0 answers

Dynamically change $primary variable in angular material theme?

Here is the case I am getting color from DB and need to set primary color into my angular website. I need to update following value in file src/assets/sass/components/_variables.demo.scss $primary: #CC2128;…
M Fayyaz
  • 145
  • 1
  • 12
4
votes
2 answers

SASS detect colour darkness to determine styles

I'm trying to make a mixin that can detect whether to show dark text (if the colour passed into buttonStyles is light), or light text (for passing darker colours). I remember there was a way to do it with LESS and wondered whether there's a SASS…
user8758206
  • 2,106
  • 4
  • 22
  • 45
4
votes
1 answer

Invalid CSS after "...-padding: (math": expected expression (e.g. 1px, bold), was ".div(100, 16) * 9);"

I try to use the vue-laravel-file-manager in my project. After I use yarn run serve, I get the error below. https://github.com/alexusmai/vue-laravel-file-manager/ ERROR Failed to compile with 1 errors …
user17384367
  • 123
  • 6
4
votes
2 answers

Sass @use not working with separated mixin files into master mixin file (ERR: Undefined Mixin)

I'm a bit newer to sass, but when I was learning it the Sass website said to start using @use instead of import, so after a lot of trial and error I finally figured out how to use it pretty much the same as import. Note: I'm using Prepros for…
Zack Plauché
  • 3,307
  • 4
  • 18
  • 34
4
votes
0 answers

How to merge/overwrite part of a @mixin in material angular theming?

Assuming there is only 1 line in the _theming.scss of material @angular/material/theming.scss that I would like to overwrite. For example: //node_modules/@angular/material/theming.scss @mixin mat-dialog-theme($theme) { $background:…
timthekoder
  • 415
  • 5
  • 16
4
votes
10 answers

How to import SCSS files into HTML files

I create a simple website project with simple HTML and SCSS. the HTML file seems like this: Hello Bulma!
user1938143
  • 1,022
  • 2
  • 22
  • 46
4
votes
2 answers

Why sometimes Chrome Dev Tool shows scss file instead of compiled css file?

As the above image shows, while inspecting some elements, the Chrome Dev Tool shows it is related with a .scss file, when I click the file, it is empty. I test it with Safari on macOS, it also shows this scss file but when clicked, it correctly…
shenkwen
  • 3,536
  • 5
  • 45
  • 85
4
votes
0 answers

Using webkit on SCSS

I'm trying to change the color of a scrollbar-thumb in my SCSS file. I tried using the scrollbar-color, but only using webkit is working. // NOT WORK .demo { scrollbar-thumb: #0f0f0f; } // WORK .demo{ //.... …
shr7
  • 163
  • 1
  • 2
  • 6
4
votes
0 answers

converting text data into PDF and download ionic 4

I tried to generate the JSON data into pdf with the below mentioned plugins. # Install Cordova Plugins > > ionic cordova plugin add cordova-plugin-file-opener2 > > ionic cordova plugin add cordova-plugin-file > > > > npm…
siva kumar
  • 41
  • 5
4
votes
0 answers

How to import fonts using Gulp/Sass?

I'm trying to import custom fonts using Gulp and Sass, but i can't figure out how. For now, i've tried many things : Create a mixin @mixin font-face($font-family, $file-path, $font-weight, $font-style) { @font-face { font-family:…
Alany
  • 367
  • 1
  • 2
  • 13
1
2
3
43 44