Topic: How to use media breakpoints in components?
webteam@rbfcu.org free asked 6 years ago
Hello,
I'm trying to use MDB media breakpoints inside components which is resulting me an error.
ERROR in ./src/app/main/main.component.scss
Module build failed:
@include media-breakpoint-up(xs) {
^
No mixin named media-breakpoint-up
in C:Repositoriesnbo-clientsrcappmainmain.component.scss (line 1, column 10)
How to add media breakpoints inside components with mdb?
@include media-breakpoint-up(xs) { ... }
@include media-breakpoint-up(sm) { ... }
@include media-breakpoint-up(md) { ... }
@include media-breakpoint-up(lg) { ... }
@include media-breakpoint-up(xl) { ... }
@include media-breakpoint-up(xs) {
.arrow_box {
display: none;
}
.main-container{
margin-top: 6em;
}
}
Damian Gemza staff answered 6 years ago
@import "../node_modules/bootstrap/scss/mixins"; @import "../node_modules/bootstrap/scss/functions"; @import "../node_modules/bootstrap/scss/variables"; @include media-breakpoint-up(xs) { .navbar { background-color: red!important; } }
webteam@rbfcu.org free commented 6 years ago
Thanks for your reply Damian. Media break points are working in styles.scss .Can we define mixins,functions,variables in global level and use them in components without specifying them in each component? ThanksDamian Gemza staff commented 6 years ago
If you need overwrite some Bootstrap styles, or use mixins from Bootstrap in component stylesheet instead of global stylesheet, you need to use encapsulation: ViewEncapsulation.None in your component.ts file right beneath styleUrls. Here's an example: @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], encapsulation: ViewEncapsulation.None }) Best Regards, Damianwebteam@rbfcu.org free commented 6 years ago
Thanks for your reply Damian. encapsulation: ViewEncapsulation.None didn't work can you provide any sample workaround? ThanksDamian Gemza staff commented 6 years ago
Are you sure, that you're doing everything in right way? You have to add in your component.scss stylesheet path to ng-mdb-pro/assets/scss/bootstrap/mixins, /functions and /variables, and they use encapsulation: ViewEncapsulation.None in component.ts file.vjaromij pro answered 6 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- ForumUser: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: Yes
- Provided link: No