Live data from Hacker News

CSS is powerful, you can do a lot of things without JS

github.com

71–80 of 319 posts

Re: CSS is powerful, you can do a lot of things without JS

#71

Still not good enough. For example the popover/tooltip that pops up on hover is fixed right below the target. If for example the viewport/window is smaller than the available space it will "bleed" out of view. You still need javascript to place it properly, and javascript that manipulates :after and :before pseudo elements is not straightforward.. Just saying :)

More to the point :target can only target one element at most, since fragment is unique. the other stuff ranges from clever tricks, like the label/checkbox modal, to stuff which would be a nightmare to maintain on a complex page

I have found that this makes it actually easier to reason about web page state: It is represented by the current URL.

Re: CSS is powerful, you can do a lot of things without JS

#72
post #12

On a side note, HTML + CSS3 is Turing complete: https://news.ycombinator.com/item?id=2300836

That is actually wrong. HTML + CSS3 + user interaction is turing complete. Yet, as Olia Lialina argues, quite a lot of software + user interaction can actually be turing complete: http://contemporary-home-computing.org/turing-complete-user/

Re: CSS is powerful, you can do a lot of things without JS

#73
post #16

Whenever someone makes a menu with CSS instead of javascript i go crazy as a user. The lack of delay is such a frustration.

You can always use transitions to add the same effect. I personally enjoy when things open quickly, some people almost fetishize transitions to an absurd level.

The bigger problem is things disappearing too quickly, e.g. as soon as your mouse moves one pixel away from a CSS hover menu it's gone.

Re: CSS is powerful, you can do a lot of things without JS

#74

Even if you can do a lot of stuff in css, sometimes you shouldn't do them. Razvan Caliman from Adobe has some good points on this topic: https://youtu.be/WupAsZGHDcY

Have you seen the whole presentation or just the first minutes? In the beginning he is showing some edge cases of css only usage, but then he actually demos some really good examples. The slides are here:

https://github.com/oslego/css-for-decoration

Re: CSS is powerful, you can do a lot of things without JS

#75
post #45
post #4

So in the first modal example, the document contains both dialog windows at the same time. Is that really what you want? Does that properly describe the content of your document?

How else would you do it, even in JavaScript?

Add it to the document when it's needed, and remove it from the document when it's not.

Re: CSS is powerful, you can do a lot of things without JS

#76

The problem with using css this way is that it's not as obvious what's supposed to happen as it is when using js. I'd love for there to be some explanation within the examples of _why_ they work - I've just been reading the first modal example but I can't really understand it

Building web applications with screens that have complex workflows and state is a need that is largely ignored by browsers and web standards. Instead of getting reusable gui components we get indechiperable css hacks that were built for creating art installations on the web rather than getting any actual work done.

Using what was supposed to be a document display format for developing application interfaces is a massive hack in the first place...

Re: CSS is powerful, you can do a lot of things without JS

#77
post #36

I think it would actually be wise to stick to JS style rendering (as is the case with React) as we're only going to see more and more styling being delegated to scripts with the rise of wasm. Only a matter of time before CSS will only really be useful for completely static websites IMO. Edit: Downvoting me because you disagree isn't really in the spirit of HN. Please provide a counter argument if you disagree, I'd be…

It would actually be wise to arm special forces with laptops, as we're only going to see more and more operations depending on hacking into security systems and building automation systems with the rise of smart devices that have no business being on the web (aka IoT). Only a matter of time before guns will only really be useful in third world countries without electricity.

Re: CSS is powerful, you can do a lot of things without JS

#78

Earlier quoted context omitted.

CSS ( properly written ) is easier to debug than JS.

Easier to find the bug harder to fix I think. The problem is CSS has a global scope - you change one thing and breaks the whole site's layout. With javascript usually code affects more specific areas of the site/web app.

If you properly modularize your CSS the global scope no longer remains a concern.

Re: CSS is powerful, you can do a lot of things without JS

#79

Earlier quoted context omitted.

CSS ( properly written ) is easier to debug than JS.

Easier to find the bug harder to fix I think. The problem is CSS has a global scope - you change one thing and breaks the whole site's layout. With javascript usually code affects more specific areas of the site/web app.

"The problem is CSS has a global scope". CSS can be written in a way that it affects only specific parts of the site/app. "you change one thing and breaks the whole site's layout". There are use-cases when you want changes to reflect across the entire site and CSS can be easily used to achieve it. (Ex: changing color of buttons). Javascript can also break the whole site's layout. It just depends on what code we write.

Re: CSS is powerful, you can do a lot of things without JS

#80
post #5

The problem with relying on anchors means it stays in the browser history, so if you press 'back', you get the modal dialog again! I don't think this is very useful, but it is a fun exercise in CSS.

Modal can be used with checkbox - and it's sweet: https://codepen.io/Idered/pen/vytkH
Post reply on HN