CSS Diner
flukeout.github.io
flukeout.github.io
You did manage to throw in a few curve balls like needing to use general and adjacent sibling selectors to select particular elements beside other elements and inside of elements. I think it should get harder a lot quicker, would be cool to see an expert CSS version of this where it starts out hard.
I can see this being used as a teaching tool.
What would be nice as a learning helper: having some display of what was actually selected with the last command. For example little hands displayed on top of the objects would somewhat match the theme.
I felt that CSS Diner is very useful even if you think you know your subject. The graphics are great. I wish all education was as much fun and as interactive.
Like many folk here I did not understand what the game was at step #1 although I forgot this at step #2. So yes, some introduction needs to be worked on even though it is easy to overlook that once you get 'absorbed'. Aside from that, brilliant and bookmarked.
Possible bug: on level 19, :nth-last-child() doesn't seem to work for selecting the first child in a set of children in firefox. Running
$("bento:nth-last-child(2)").length
is coming up 0 in the console as well.edit: these work though :/
bento:nth-last-child(even)
bento:nth-last-child(1n+2)
bento:nth-last-child(2n+0)
edit 2: Ahh figured it out. :nth-last-child doesn't match only nodes that satisfy the selector you called it on. It matches all sibling nodes of the selector you called it on.edit 3: Actually, I don't know what I'm doing. It might be a bug. I can't tell anymore. Anyone else have any thoughts?
edit 4: OK, I finally get it... nth-last-child() is a qualifier not a grouper(I don't know the actual css terms so I made those up). That is to say that when you specify bento:nth-last-child(2) you're not saying "of all the bentos give me the second one" you're saying "of all the bentos give me those that are in the second child position."
According to the description on level 18
div p:nth-child(2)
selects the second <p> in every <div>So on level 19, to select the first <bento> in <div>,
div bento:nth-child(1)
should work, but it doesn't. However, div bento:nth-child(2)
works. So I think a possible bug here? .table *:nth-last-child(4)
Seems to work, although for me I had to push enter a few times.It selects the <bento> element that is the 4th child from last.
I think the confusion is here: people think that bento:nth-last-child(2) will be the solution because it should select the second-from-last bento element, but what it does is it selects all bento elements which are the 2nd from last children -- and since in the puzzle there is no bento that is second from last, it selects nothing.
So you have to consider it's siblings. The one we want ot select is the 4th-from-last among its siblings.
Adding the bento: should have removed all the other items from selection.
It sounds like you are explaining a selector such as *:nth-last-child(4)
There is a good reason, though, and it's in keeping with the 'nth-of-type' selector logic: there is a selector that works the way you think, called nth-last-of-type[0]
[0] http://www.w3schools.com/cssref/sel_nth-last-of-type.asp
[sample page I made just for you on my github.io page] http://flanneljesus.github.io/
I learned a lot today. Thanks for posting this in the thread.
One notable issue: several puzzles need to have additional elements or classes added to prevent less sophisticated solutions from working. It's often possible to use a simpler selector than the one being taught in a particular puzzle.
On level 7, it's possible to ignore the intended lesson and use "plate .small, bento .small".
On level 10, surprisingly, it's not possible to ignore the intended lesson and write "apple, orange, bento, plate".
On level 11, .table * * works, though that does use the intended lesson.
That's in addition to the ones already mentioned in the sibling comment, which were the first ones I noticed.
It would be interesting if the answers were tracked so we could eventually see what different developers were entering as selectors on each one.
orange:last-of-type, apple:last-of-type
while this worked: apple:last-of-type, orange:last-of-typeAll in all pretty fun, the tips on the right make it fairly trivial to trudge through if you're not great at CSS (like me.)
1. Would be nice to have some sort of 'hint' or 'solve' button.
2. Since you have the copy regarding how it's a work in progress, I'd suggest throwing a link to the github issues page so it's easy to submit bug reports and whatnot.
3. I like it. Really aesthetically pleasing to use and each level is such a small incremental step forward I think that even the most timid of noobs would get a kick out of using it.
Did you see the CSS documentation on the right sidebar? It took me a while to notice it was there.
I couldn't for the life of me 'unstick' myself from my initial answer. The hint could have kinda slapped my brain and jolted the more concise answer outta me.
Really minor detail I know, but with a lot of these online lesson helpers people do like to have the answer available to them.
Apparently "plate pickle, bento pickle" (or reverse order) isn't correct. Would love to see a hint/solution manual.
Anyone have any examples of how they have or would use these in real-life?
input:valid + label { color: black; }
input:invalid + label {color: red; }
CSS Tricks has a tutorial (http://css-tricks.com/float-labels-css/) on this technique for displaying form labels as faux placeholders until the input has content, although it's not quite ready for most site's production requirements.
I haven't found many uses for the general sibling selector `~`, as it matches all elements after the initial selected element. I usually want the preceding elements as well if I'm shooting that broadly, so simply excluding the item with `:not()` is generally a better choice.
:checked + label { background-color: green; }
http://jsbin.com/witaziwu/1/edit?html,css,output Small demo if you want to mess around with it.
https://code.tutsplus.com/tutorials/the-30-css-selectors-you...
Here's the GitHub repo in case anyone wants it:
https://github.com/flukeout/restaurant
(couldn't find a link anywhere)
- The instruction (e.g. 'Select the small apples') isn't noticeable enough.
- There needs to be a pause after you get an answer right, so you can work out why you got it right (otherwise you can bang away at random combinations until you get to the next step without any idea what worked).
- Similarly, when you try a wrong answer, there needs to be feedback as to why. E.g. if you try 'bento small plate', when the answer is 'bento #small plate', then there needs to be an explanation as to what you didn't do. This is not trivial to achieve!
- The instructions at the right hand side is visually noisy, and should be hidden until needed, or perhaps presented first (in a modal popup) to give the visitor a heads up as to what they are supposed to be adding to their knowledge.
- Because of the right hand instructions, it's not initially clear that the HTML code is at all part of 'the puzzle'.
You are 90% there, just the last 90% to make it a true gem of a teaching tool.
It took me some time to figure out what I needed to do. Immediately, when I see "select," I think "click," so I clicked on the item instead of typing in text. Consider saying, "select images by typing in their class below."
Instead of ".classname," give an example. Also consider a pop up tutorial or a guide that shows you what to do on the very first lesson.
The list of lessons is also confusing. There needs to be something that says - this is what you've learned and what you still have to learn. Otherwise it just looks like a strange list of words from a language I don't know.
Also - consider putting the instructions on the left hand side, and putting "Learn CSS!" or something at the top instead of "Select ???." Because I read from left to right, right now I see the image first, an instruction to select something on the image (which I and others will interpret as "click on the image") and then I stop (rather than go all the way across to see the other instructions). If I see the instructions first and know exactly what to do.
Great job on this!
The pickle and apple shook, but apparently I was "wrong."
But what I liked most, is that as someone with very little experience in writing CSS, this allowed me to breeze through the simpler selectors, while building my confidence on the more complex selectors. No doubt the graphical representation was extremely helpful in that regard.
A resource worth sharing.
I'm not sure if a beginner will retain much by going through each selector for each level - would be nice to throw in some levels that require you to think back to previous selectors. However, it's a good review for someone who's been exposed to them before.
Select every pickle to the right of the bento
The solution `bento ~ pickle` passes, but I don't think it should. It does not select the pickles on the plates that are to the right of the bento.
Anyways, very awesome way to teach, I'm sharing it with all my friends but would be cool to force the solution and prevent "hacks" :P
Does anybody know other games like this in HTML, Javascript and Rails?
This looks great for teaching beginners CSS, although there should be an "instructions" message somewhere.
e.g.: A + B > C .small
For # 16, I tried the following which did not work:
pickle:only-child, apple:only-child
However, this worked: apple:only-child, pickle:only-child plate :only-child :only-childI'm on the current version of Chrome and it's throwing a load of JavaScript errors in the console so maybe that's got something to do with it.
I'm yet to find a case that has absolutely required the use of the universal selector. Has anybody else?
[0] https://developers.google.com/speed/docs/best-practices/rend...
[1] https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_s...
Level 17 of 26: Select the small apple and the pickle
Does not accept .table > :last-child, apple.small
does accept
apple.small, pickle
Level 19 of 26: Select the 1st bento:
Does not accept .table > :nth-last-child(4)
does accept: bento:first
Thanks for creating it!
Very good, thank you! :)
overall this is great
>Fails thus far: 5