Live data from Hacker News

The Tilde is an Amazing CSS Selector

nicholsonws.com

1–10 of 31 posts

Re: The Tilde is an Amazing CSS Selector

#4
post #2

Can't say I understood what it does from that post, so here's another description: http://reference.sitepoint.com/css/generalsiblingselector

It looks like it's just taking the place of having to attach an event to the radio button, doing a lookup on the sibling #find_me element and manipulating it's style via JS.

These types of things are great, the more we move away from JS DOM hacks the better.

Re: The Tilde is an Amazing CSS Selector

#5
post #2

Can't say I understood what it does from that post, so here's another description: http://reference.sitepoint.com/css/generalsiblingselector

I had no idea what ~ did after reading that post. Should have simply stated that:

"The tilde (~) selector lets you target a sibling element. That is, an element that shares the same parent"

Could then explain how it's different than the + selector.

"This differs from the + selector which will only find an adjacent sibling (immediately following)."

I'd consider comparing it to the child and descendant selector, if I could word it properly. This is what I have which I'm not happy with:

"In some ways, the differences between + and ~ are like the differences between the child selector (>) and the descendant selector (a space), in that #header > a will only a elements directly under #header, while header a will target all a elements under #header, regardless of depth.

Re: The Tilde is an Amazing CSS Selector

#6
This post abuses IDs. If you have something with the ID #main, it should be unique anyways or else you have invalid markup. If it's unique, why do you need a sibling selector to find it?

This post could be improved by using classes:

    #container input:checked ~ .main > .findMe { ... }
But really, the sibling selector is powerful enough that you might not need classes at all. I think the following selector makes a much more powerful statement of the kind of thing you can do now that you couldn't before:

    input:checked ~ div span { ... }

Re: The Tilde is an Amazing CSS Selector

#7
post #5
post #2

Can't say I understood what it does from that post, so here's another description: http://reference.sitepoint.com/css/generalsiblingselector

I had no idea what ~ did after reading that post. Should have simply stated that: "The tilde (~) selector lets you target a sibling element. That is, an element that shares the same parent" Could then explain how it's different than the + selector. "This differs from the + selector which will only find an adjacent sibling (immediately following)." I'd consider comparing it to the child and descendant selector, if I c…

This is far better then original article. +1

Re: The Tilde is an Amazing CSS Selector

#9
There already are many CSS3 sliders created using the 'tilde' selector.

http://cssdeck.com/item/348/pure-css3-content-slider

http://cssdeck.com/item/308/awesome-rotating-css-image-slide...

http://cssdeck.com/item/153/solitary-css3-slider-rotation-tr...

http://cssdeck.com/item/363/simply-css-image-slide

http://cssdeck.com/item/364/pure-css3-slideshow-without-page...

Post reply on HN