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 trialjack duong
Courses Plus Student 100 PointsHow do I import custom css file into main.scss? I can't get it to work.
I created a 'layout' folder under _sass, and made a new file called '_index'.scss.
In the index file I change the background-color for body to black. Then in the main.scss I put @import "layout/index".
When I start the server, the background color doesn't change , and I don't get any error messages either.
vryiziilos
Full Stack JavaScript Techdegree Student 23,052 PointsHmm.. this could be a specificity issue. Are you changing background color for body anywhere in your main.scss file. It could be overriding _index.scss body rule.
Steven Ventimiglia
27,371 PointsTry using:
body {
background-color: #000 !important;
}
...to see if that makes any difference. If so, then you're defining the background-color to be something else, later on in the styles.
Also, If your main.scss file is located at "http://www.yoursite.com/css/main.scss", and is compiled to create "http://www.yoursite.com/css/main.css", including @import "layout/_index.scss", then it would be looking for "http://www.yoursite.com/css/layout/_index.scss".
I would recommend keeping all .scss files in one directory for a less confusing structure (at the beginning, at least.) So you can have "http://www.yoursite.com/css/main.scss", which will easily be configured to use:
@import "_reset.scss";
@import "_index.scss";
@import "_theme.scss";
...so the directory listing would be:
_reset.scss
_index.scss
_theme.scss
main.css
main.scss
If _index.scss had the body's background-color set to #000, and _theme.scss had it set to #fff, then the background-color would be defined as #fff since that "cascaded" over the previous value. !important would force the first value to take precedence, overwriting whatever followed it (unless that was defined as !important, as well.)
EDIT: Sorry for any spelling mistakes. Autocorrect was being evil.
Joni Carlson
11,940 PointsDid you check the spelling? Did you intend main.scss or main.sass?
1 Answer
jack duong
Courses Plus Student 100 PointsThanks everyone! I took Stevens advice, and setup my css files in one directory and it worked lol. So I basically linked it to the wrong location. Can't believe the amount of time I spent on this. Thanks for the help!
Anupam Majhi
5,826 PointsAnupam Majhi
5,826 PointsCan you please share your workspace?