TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Styling with Classy CSS (2006)

123 pointsby jacobrover 1 year ago

7 comments

micromacrofootover 1 year ago
I feel like utility classes had their moment and we can now start to pull back towards semantic CSS with the help of new features like CSS custom properties.<p>Instead of .f-green in your HTML you can do --f-green in your CSS.<p>&lt;header class=&quot;f-green&quot;&gt;&lt;&#x2F;header&gt;<p>would become<p>header { color: var(--f-green); }<p>or if you really hate CSS and must stay in HTML<p>&lt;header style=&quot;var(--f-green)&quot;&gt;&lt;&#x2F;header&gt;<p>Though the literal naming is a touch too specific anyway. Something like this is wonderful:<p>--f1-color: green;<p>header { color: var(--f1-color); }<p>then you don&#x27;t have to do confusing things like<p>header .f-green { color: red; }<p>because you can do<p>header { --f1-color: red; }<p>So we can be less specific AND more modular... because you can have that f1 (font1) color be red in your header, and still do:<p>footer { --f1-color: green; }<p>We can make really flexible and extensible systems with modern vanilla CSS. No frameworks or preprocessors needed.
munk-aover 1 year ago
It&#x27;s extremely important to create classes like `.f-green` in case the definition of green ever changes. That&#x27;s what we call forward portability.<p>Also, if your company rebrands from green to red you can just `.f-green {color:#f00;}` - it&#x27;s so efficient!
评论 #38116694 未加载
评论 #38119871 未加载
评论 #38118682 未加载
评论 #38118707 未加载
评论 #38116921 未加载
cantSpellSoberover 1 year ago
Yep, Tailwind didn&#x27;t invent style tokens or composable classes! After learning Foundation, Tachyons, Material UI, Chakra...I was happy to see we finally settled on Bootstrap.<p>Oh, we didn&#x27;t? Well, time to learn a new syntax. (Was it `<i>dark:md:hover:</i>text-slate-400` or `<i>hover:md:dark:</i>text-slate-400` again?) At least Tailwind arguably has more benefits than its predecessors.
评论 #38118812 未加载
评论 #38120432 未加载
Julesmanover 1 year ago
I will always argue against this. Keep your layout in one file and your styling in another. I&#x27;ve done more CSS than most in heavy web production and I never once had a reason to think something like this would be faster or more efficient.
评论 #38119040 未加载
评论 #38124600 未加载
评论 #38118900 未加载
tuyiownover 1 year ago
So visionary to be considered a wtf. Thanks for the submission, made my day !
评论 #38120174 未加载
评论 #38118765 未加载
Brajeshwarover 1 year ago
This is what I did before stumbling on BEM - <a href="https:&#x2F;&#x2F;en.bem.info&#x2F;methodology&#x2F;css&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.bem.info&#x2F;methodology&#x2F;css&#x2F;</a>
评论 #38116393 未加载
i0nutzbover 1 year ago
Back in the day we made fun of this nonsense, now we freakin glorify it with libraries like Tailwind &amp; friends...
评论 #38115561 未加载
评论 #38120210 未加载
评论 #38117166 未加载
评论 #38115241 未加载
评论 #38123486 未加载
评论 #38115207 未加载