Actually what I am typing in is just basically CSS these days. Back in the day SCSS gave you key additional options like nesting and custom variables, but these are now built in to CSS.
/* global variables */
:root {
--text-main: black;
--text-accent: crimson;
}
section.hero {
/* local variable overwrites the global */
--text-main: rgb(20, 20, 20);
.section-title {
color: var(--text-accent); /* from global variable */
}
.section-container {
display: flex;
}
img {
border-radius: 0.25rem; /* 4px */
}
p {
color: var(--text-main); /* will take the local version */
}
}
Using this in SCSS it will be compiled to an un-nested version and add any browser specific prefixes that might be needed. e.g.
...
section.hero {
/* local variable overwrites the global */
--text-main: rgb(20, 20, 20);
}
section.hero .section-title {
color: var(--text-accent);
/* from global variable */
}
section.hero .section-container {
display: flex;
}
...
I tend not to differentiate between devices and donât use standard sets of breakpoints (but thatâs just the way I work).
Each of my breakpoints are based on the section/element in the design that needs to change when it looks awkward or doesnât fit. That breakpoint will not be the same for any other sections most likely. It also means that if I need to tweak the width for one section I donât end up changing all the others at the same time.
Again, thank you for everything and what a learning experience. I am currently using Visual Studio 2022 with Asp.Net Core MVC. I did some research regarding SCSS and it seems like everyone is saying its the future, but it sounds like you are saying basic CSS will do the same. So in addition to the project at hand, I am trying to learn new sikills, but not sure which ones.
I am completely lost on how you got the âAboutâ effects. I love it, but between the SCSS and the more complex CSS, I canât figure it out. Sorry I am so dumb.
If you look at Russâs pen in editor mode then you can go to the middle css panel and click the little arrow on the right and select âview compiled cssâ and it will show you the SCSS as normal CSS which you can then copy as normal css.
No youâre not. Learning CSS can be difficult. âCSS The Definitive Guideâ fifth edition I purchased a few months ago is 1000+ pages, which illustrates itâs not a 5 minute exercise.
Hopefully this diagram will help. Note I have changed max-width to 800px, for the purposes of making a diagram.
Thank you again for all of your efforts. This is extremely helpful and I was unaware of the newer features. I am intrigued by the values in @layer base and how they are used. Is this basically a method of declaring the colors in one place in order to carry them through the entire stylesheet?
Personally I am using them for grouping and organising my css. I am following Kevin Powellâs naming convention of âresetâ, âbaseâ, âlayoutâ, âutilitiesâ and âcomponentsâ. You could call them anything you like.
With regards carrying the colour variables throughout the entire stylesheet, yes, but that is done by declaring them inside :root
Basically rules defined in :root are top of the tree, and those rules will cascade down to child elements