TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What do you think of the anti-CSS debate?

10 点作者 donjh将近 10 年前
I've been hearing more and more about the concept of applying inline styles through JavaScript as opposed to using CSS. There's been an article floating around regarding the idea, too (https://css-tricks.com/the-debate-around-do-we-even-need-css-anymore/). What's your take?

7 条评论

pixellab将近 10 年前
As someone who writes CSS frameworks for a living, I don't know if I could ever give up the powerful globalness of the "c" (cascading.) Though, I do find myself writing more and more inline styles for elements that are specific to a block or page to avoid bloating the framework. I'm thinking a blended approach is in my future.
bjourne将近 10 年前
I think he is glossing over CSS main selling point which is a separation of concerns. Essentially, you can code a web-site unstyled and then let an independent 3rd party write a style sheet for it.<p>He is saying that you would have a &#x27;style.js&#x27; performing the task, but he is not specifying exactly how that file would replace the &#x27;style.css&#x27;. A designer writing the &#x27;style.js&#x27; key-value pair seems implausible as does converting a designer-created &#x27;style.css&#x27; to &#x27;style.js&#x27;.
jdeisenberg将近 10 年前
Random thoughts: As far as I understand it, CSS is declarative. JavaScript, not so much. The declarative aspect of CSS is nice; you just specify what you want and CSS handles everything else for you.<p>I am also idly wondering how this would all work out in &quot;HTML and CSS as s-expressions&quot; à la Ŝablono <a href="https:&#x2F;&#x2F;github.com&#x2F;r0man&#x2F;sablono" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;r0man&#x2F;sablono</a>
seaneking将近 10 年前
To me this is a bit of a &#x27;baby with the bathwater&#x27; scenario. CSS has problems (particularly lack of namespacing), but I don&#x27;t think the solution is to just pack up shop on stylesheets and port everything to js. If the argument is about logic, then postCSS and manipulating the CSSOM are cleaner approaches IMO. And with web components the modularity concern is pretty much entirely mitigated. There&#x27;s definitely an argument to be made about javascript&#x27;s role styling, but I think it should be complimentary alongside the purely declarative stylesheet.
n17r4m将近 10 年前
Personally, I think there is a lot of magic yet to be discovered in dynamically manipulating the CSSOM (CSS Object Model).<p>Case study: If trying to manipulate some ~100 inline-block elements into a grid, with dynamic (say, zoomable + pannable + screen size dependant) width, height and offset. It makes way more sense to programmatically modify the stylesheet using the CSSOM API with fast calculated values, rather than applying unique styles to each of those 100 elements in the DOM, O(1) vs O(n) - yes?
vezzy-fnord将近 10 年前
Ironically enough, Netscape proposed a JavaScript Style Sheets specification back in 1996 to replace CSS, but was rejected for being too complicated: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;JavaScript_Style_Sheets" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;JavaScript_Style_Sheets</a>
helpmeimpoor将近 10 年前
I hope html and css bending become one language is there any language like that to make a webpage?
评论 #9797292 未加载