Here is my setup:
File Relationships
home.php <---styles---- _layout.scss
|
imports
|
v
animation.html <---styles---- _animation.scss
home.php - the file used to outline the "layout" HTML for the homepage:
<div id="animation">
<div class="site-container">
<div class="animation-container">
<?php include 'animation.html'; ?>
</div>
</div>
</div>
_layout.scss - the files used to style the non-imported contents of home.php:
#animation {
//styles <div id="animation">
}
.site-container {margin: 0 auto; max-width: 980px;}
.animation-container {
//styles <div class="animation-container">
}
animation.html - contains the html for the "module" called "animation" imported above
<div class="animation-wrap">
<div class="example-selector"></div>
//more html for animation module
</div>
_animation.scss - styles the html in animation.html
Question: How should I be encapsulating the selectors in _animation.scss?
Possibilities
1.) I could nest all selectors in _animation.scss like so:
.animation-wrap {
.example-selector {
}
//all other selectors are nested here using SASS, thus they will not affect
//elements outside of the animation-wrap
}
2.) I could namespace almost all selectors in _animation.scss by adding the prefix "animation-" (and in the corresponding html)
.animation-wrap {}
.animation-example-selector {}
3.) Could use child selectors to reduce cascading, but I doubt that's best and it has poor IE support
4.) Subclassing? But, I think that is more relevant to moving the module elsewhere, not encapsulating it to make sure it doesnt leak into other module/layout code
Sorry for the long-winded question, it was awkward to put into words. Any additional advise or knowledge of best practice is greatly appreciated