I created a mixin css file
//Breakpoint
@media (min-width: 64em) {
//styles go here
}
//640px, 1024px, 1400px
$breakpoints-up: ("medium": "40em", "large": "64em", "xlarge": "87.5em");
// 639px, 1023px, 139px
$breakpoints-down: ("small": "39.9375em", "medium": "63.9375em", "large": "87.4375em");
@mixin breakpoint-up($size) {
@media (min-width: map-get($breakpoints-up, $size)) {
@content;
}
}
@mixin breakpoint-down($size) {
@media (max-width: map-get($breakpoints-down, $size)) {
@content;
}
}
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
and then i tried to implement it in my global css file
.hide-for-mobile {
//Hide for tab and mobile
@include breakpoint-down(medium) {
display: none;
}
}
.hide-for-desktop {
//hide for desktop
@include breakpoint-up(large) {
display: none;
}
}
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
although the global and mixin files are part of the imports in my main css file
@import "globals";
@import "mixins";
@import "variables";
@import "headers";
<iframe name="sif3" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
at the end it gives error
Compilation Error
Error: no mixin named breakpoint-down
on line 63 of sass/c:\Users\USER\Downloads\Project\app\scss\_globals.scss
from line 1 of sass/c:\Users\USER\Downloads\Project\app\scss\style.scss
>> @include breakpoint-down(medium) {
<iframe name="sif4" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
I believe the issue might be that you're importing globals
before you're importing mixins
. Because of this, at the time globals is called there isn't a mixin called breakpoint-down
: it's not been defined yet. To fix it, you might just need to switch the imports around
@import "mixins"; // First instead of second
@import "globals";
@import "variables";
@import "headers";
hope this helped :)