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

Moving icon in-front of the content

Haris
  • 83
  • 5
-1
votes
1 answer

SCSS - How to avoid extra space when intrapolating variable in content propery

I have a simple mixin like this: @mixin icon_fn($glyph) { &::before {content: "\e#{$glyph}";} } so that I can use it as simply as @include @icon_fn("9fa") but for some reason there's always a space between \e and the variable. Can't figure out a…
Moseleyi
  • 2,585
  • 1
  • 24
  • 46
-1
votes
1 answer

How does SCSS choose which class to use if more than one matches the element?

If I have HTML like this: And LESS that looks like this: .class1 { color: green; } .modal { .class1 { …
mcool
  • 457
  • 4
  • 29
-1
votes
1 answer

Dynamically add colors into component

I have 2 components. The first component sets colors that I then use in my second component however I have to set every color individually which I do not want to do. I am trying to possibly add an array that I can add the colors inside instead of…
skydev
  • 1,867
  • 9
  • 37
  • 71
-1
votes
1 answer

Smallest Scss Media Query not applying

So im just testing some media queries for scss in my webpack project. I've just got a simple div within the body, and want the background to change depending on the width of the screen. My two smallest media queries, small & xsmall, just don't…
DMDEV
  • 25
  • 4
-1
votes
1 answer

CSS Media Query For Mobile Not Applying

Goal: See the h1 font-size resize when it hits the 375px screen size. What is actually happening is that it is applying the styles for the size 1303px screen. It's crossing out the media query that would actually apply at that screen size…
grimreaper
  • 35
  • 6
-1
votes
1 answer

How do i select a specific sibling class under a parent class?

I have two parents classes that have the same name but one has additional child class. I want to only select a child class from the parent class with that additional child class. class = money-styling class = compare-at-price class =…
-1
votes
1 answer

css/scss: is there a way to clean this up and make it dryer?

I have a class content and isActive. Do I have to "include" the mixin twice like below so that it would apply when I have an element like
and
.content { padding: 0 40px; &.isActive { …
user15909643
-1
votes
1 answer

Using all scss features in a project necessary?

Is it really necessary ? like loops , list etc ... Is using those feature really necessary in a project ? Yes,Mixins,Variables,Extend,Nesting,PartialImport are necessary . But are other functions , loops ,list really used on daily basis on…
Kshitiz
  • 23
  • 5
-1
votes
1 answer

How to give opacity to background-color using Saas variables color themes mixins?

This is my mixins for themes color $themes: ( light: ( black-color: black, ), dark: ( black-color: rgb(235, 13, 161), ) ); @mixin themify($themes) { @each $theme, $map in $themes { .theme-#{$theme} & { …
-1
votes
1 answer

Why css styles leaks (gets inherited by other components) out of the component when they use the same class names in react.js?

I have created two separate components in my 'create react app'. For each component, I have a dedicated style sheet. If I use the same classNames inside both components then the style gets inherited to the other component as well. Here, In my case…
Nishant Kumar
  • 691
  • 1
  • 11
  • 31
-1
votes
1 answer

Is using SCSS maps this way bad practice?

Is this bad practice or why does nobody do it? I'd considere this as really helpful with certain properties you'd use over and over again through larger projects, like your own framework etc, since it keeps the code short and makes it easy to…
Simplicius
  • 118
  • 6
-1
votes
1 answer

Reuse css elements

I have two scss files. Eg. SCss1 and scss2. Scss1 has styles for many components and I want to reuse the style in scss2 but without copy and pasting the same code as that would be repetition of code and I want to avoid that. I need an scss2 file…
EverydayDeveloper
  • 1,110
  • 4
  • 11
  • 34
-1
votes
1 answer

Cannot read property 'toString" of undefined -- React

Link to CodeSandbox. I was about to start working on this app again. It worked perfectly about a month ago, however now I get the error: Cannot read property 'toString" of undefined It doesn't pinpoint where the error is either.
JD Fill
  • 392
  • 2
  • 7
  • 24
-1
votes
7 answers

CSS calc function does not center

I need to use the calc function for width but it doesn't divide distance around. HTML
SCSS .container-card { background-color: grey; height: 500px; …
heliya rb
  • 682
  • 8
  • 26
1 2 3
43
44