/    Sign up×
Community /Pin to ProfileBookmark

SCSS doesn’t work

Hello. I have placed these three files into the same folder on a local harddrive, and it doesn’t work.

https://www.w3schools.com/sass/showsass.php?filename=demo_sass_first

There is no reference in the mypage.htm nor in the mystyle.css about the existence of the mystyle.scss file. If I change the value of the variable $bgcolor in the style.scss file to red, it does not influence the mypage.htm background color.

How to make it work? Thank you.

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJul 19.2021 — An scss file cannot be included directly in a HTML file. It needs some preprocessing converting it to normal CSS:

https://developer.mozilla.org/en-US/docs/Glossary/CSS_preprocessor

I started dealing with scss some time ago but didn't find a significant benefit in using it, as the additional features, e. g. loops, were limited. Therefore I didn't dive into further.
Copy linkTweet thisAlerts:
@codewitchauthorJul 19.2021 — Hello Sempervivum. Thank you for your reply.

Indeed, there is a need for some **transpiler** to process the code and convet it into an css code.

I find it useful for define a single color that is used repeatedly and can be saved as a content of a variable, but otherwise I also fail to see the benefits of SASS.
Copy linkTweet thisAlerts:
@SempervivumJul 19.2021 — @codewitch#1634382
>I find it useful for define a single color that is used repeatedly and can be saved as a content of a variable

That's possible without SCSS:

https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties
Copy linkTweet thisAlerts:
@codewitchauthorJul 19.2021 — Thank you! There is something new to learn every day.

<i>
</i>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;style&gt;
:root {
--my-color-1: green;
--my-color-2: blue; <br/>
}

.myclass1{color: var(--my-color-1);}

.myclass2{color: var(--my-color-2);}


&lt;/style&gt;
&lt;body&gt;

&lt;div class=myclass1&gt;hey I am a cool text in green&lt;/div&gt;

&lt;br /&gt;

&lt;div class=myclass2&gt;hey I am a cool text in blue&lt;/div&gt;


&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @codewitch spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...