Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Bruno Dias
10,554 PointsBEM - Where to include modifiers for specific pages?
I am trying to use BEM naming convention and having some slight difficulty in deciding where to include a modifier for a specific page.
For example, say I have a button with the class btn:
My project has 3 different pages:
- pageA.html - pageA.scss
- pageB.html - pageB.scss
- pageC.html - pageC.scss
On pageB.html the button should have a margin-top:30px. Is it correct to write the modifier this way:
.btn {
padding: 5px 20px;
background: orange;
margin: 0
&--margin-top {
margin-top: 30px;
}
}
And what is the best way to include a modifier like that only for a specific page? In this case that would be for pageB.html. Should I include that modifier inside the pageB.scss or buttons.scss?
cc: Guil Hernandez
1 Answer
Jason DeValadares
7,190 PointsI'm not familiar with BEM but why do you have a different CSS per page? I'd just give it specific class modifiers in a drill down. As for your CSS question you can short hand it like this:
.btn {
margin: 30px 0 0 0;
}
or you can do:
.btn {
margin-top: 30px;
}