News for hackers. Stuff that matters.
Re:The Shapes of CSS by chrisacky on Saturday May 26, 2012 @10:39AM (#4027371)
I love the Space Invader style from this article. I'm making a 20 second animation for the game now... give it an hour and then post what I have.

Here is the current.. (ONLY WORKS ON WEBKIT) - Will add animation for other vendors once I have finished.

----

Space Invader Animation CSS3 Only

http://jsfiddle.net/dd454/20/show

Re:The Shapes of CSS by jarek-foksa on Saturday May 26, 2012 @11:49AM (#4027536)
CSS was never meant to be used for drawing complex shapes. If you are using those hacks instead of proper SVG or canvas paths then you are doing it wrong.
Re:The Shapes of CSS by pacomerh on Sunday May 27, 2012 @03:34AM (#4029551)
Wow what you wrote is actually the oposite of the definition of what 'hacker' means, a few kittens died with that comment. What happened to being inventive?.
Re:The Shapes of CSS by Achshar on Sunday May 27, 2012 @01:24PM (#4030514)
That's exactly what someone must have said when people were using tables for site structure and someone like OP tried to correct them.

Hack is essentially to get things done. In no way does it mean write new specifications.

Re:The Shapes of CSS by rytis on Saturday May 26, 2012 @01:51PM (#4027860)
Totally with you on this. Really sad to see that a "triangle" is actually a "border"! Seriously, WTF?! Or is it just me, and everyone else is ok with that?
Re:The Shapes of CSS by liamondrop on Saturday May 26, 2012 @05:13PM (#4028382)
Just you. It's an exercise meant to push the boundaries and get people thinking creatively. Also, the triangle thing is a pretty common and useful hack.
Re:The Shapes of CSS by vibrunazo on Saturday May 26, 2012 @05:21PM (#4028406)
It's just a funny thing to giggle at. But I really hope no one will use this in production.
Re:The Shapes of CSS by alecperkins on Sunday May 27, 2012 @01:03PM (#4030467)
I'm currently working on a site that uses it heavily in production for visual enhancements and details. It's a great trick that works well, and doesn't require any additional markup if you use :before and :after pseudo-elements. Using CSS instead of images means it's easy to programmatically manipulate it, as well. eg A color picker system with a notch that varies with the color being picked. The new Google+ design uses the triangle trick with a twist, making an open triangle that shows what's underneath it, like your cover photo.
Re:The Shapes of CSS by malandrew on Saturday May 26, 2012 @06:45PM (#4028618)
It's used all the time in production to produce the arrow effect on tooltips and similar elements.
Re:The Shapes of CSS by tylermenezes on Sunday May 27, 2012 @01:04AM (#4029305)
So what, the solution is draw it in canvas? What about the large number of people without support? I understand not using it for circles, but I've actually seen the triangle bit used quite often, and it makes sense.
Re:The Shapes of CSS by rrreese on Saturday May 26, 2012 @12:10PM (#4027593)
Can you explain why this is wrong? I appreciate this was never intended, but what is actually wrong here?
Re:The Shapes of CSS by jarek-foksa on Saturday May 26, 2012 @01:46PM (#4027849)
What makes it wrong is the fact that we already have means for describing complex graphics that are:

  - more readable
  - easier to maintain
  - easier to tweak
  - much more powerful
For similar reasons it's considered to be wrong to use HTML tables for page layout instead of CSS.
Re:The Shapes of CSS by yuvadam on Saturday May 26, 2012 @10:36AM (#4027365)
I wonder if the last space invader example can be extrapolated to generate any arbitrary pixel art.
Re:The Shapes of CSS by lbotos on Saturday May 26, 2012 @11:27AM (#4027483)
I think it could be for one color pieces, but anything beyond that and it makes a lot more sense to use an svg or div based solution.
Re:The Shapes of CSS by zevyoura on Saturday May 26, 2012 @07:34PM (#4028713)
It makes more sense to use an svg based solution for almost all of these examples also.
Re:The Shapes of CSS by golden_apples on Sunday May 27, 2012 @12:33PM (#4030375)
Yes, since each ” pixel” is just an additional box shadow. Very clever. I've never experimented with the number of box shadows that can realistically be drawn on modern browsers, winner what that limit is?

This technique could be used for evil very easily.

Re:The Shapes of CSS by samsonasu on Saturday May 26, 2012 @12:47PM (#4027680)
Cool demo, made even cooler because they stuck "contenteditable" on the style tags so you can play around with the shapes to see how they work right in the browser.
Re:The Shapes of CSS by madeofchalk on Sunday May 27, 2012 @04:09AM (#4029619)
That's actually really interesting. Never knew you could put contenteditable on a style tag and have it work like that.
Re:The Shapes of CSS by secoif on Saturday May 26, 2012 @07:10PM (#4028664)
Right Click -> Inspect Element
Re:The Shapes of CSS by samsonasu on Sunday May 27, 2012 @01:49AM (#4029385)
I haven't seen a way to edit CSS on the before and after pseudo elements in the web inspector. If I'm missing something I'd love to know about it.
Re:The Shapes of CSS by madeofchalk on Sunday May 27, 2012 @04:08AM (#4029617)
Its there, plain as day. http://cl.ly/GwZz
Re:The Shapes of CSS by kjhughes on Saturday May 26, 2012 @04:57PM (#4028346)
Interesting collection, but as the intro states: Any kind of CSS goes, as long as it's supported in at least one browser.

More impressive and useful would have been a reasonable floor above which the tricks were guaranteed across browsers. ...or at least a compatibility note next to each technique. For example, IE 8 can't handle rounded corners, so infinity, egg, packman, talk bubble, etc do not work at all. Version 8 is as high as Windows XP users can go with IE, so there's a lot of IE 8 out there still.

Re:The Shapes of CSS by gpmcadam on Sunday May 27, 2012 @12:47PM (#4030416)
Most everyday problems related to rounded edges in CSS can be solved with CSS3 PIE (http://css3pie.com/).

How well these shapes would render though, I don't know.

Re:The Shapes of CSS by factorialboy on Saturday May 26, 2012 @10:49AM (#4027389)
Nice!

A month ago I remember struggling to create those triangle pointy arrows for tool tips.

I was an idiot for not using Twitter Bootstrap in that project.. :-/

Re:The Shapes of CSS by isnotchicago on Sunday May 27, 2012 @08:26AM (#4029977)
Has anyone else noticed that at certain zoom levels, the triangle in the talk bubble looks disconnected by one pixel from the box? I have seen this problem with any similar use of the triangle hack.
Re:The Shapes of CSS by alecperkins on Sunday May 27, 2012 @12:58PM (#4030452)
Yes, I've seen that often. It's most apparent even without any zooming on mobile Safari. For this reason, whenever I use the triangle effect, I'll offset the element/pseudo-element by one pixel to avoid the gap.
Re:The Shapes of CSS by isnotchicago on Monday May 28, 2012 @12:01PM (#4033899)
Any ideas on a fix that works when the triangle must perfectly align with a box? In other words, when the base of the triangle should be the same width as the side of the box it touches. In this case, moving the triangle one pixel closer to the box means it does not fit perfectly against the box.

Example: http://jsfiddle.net/PLMSA/

Re:The Shapes of CSS by alecperkins on Monday May 28, 2012 @01:23PM (#4034187)
Since it's basically a rounding error, I'm not sure if there's any way to avoid the gap without some overlap. In that example, a :before pseudo-element that's the same width as the box and one pixel above the triangle can provide the overlap without needing to offset the triangle itself.

http://jsfiddle.net/enTz9/

Re:The Shapes of CSS by delan on Saturday May 26, 2012 @09:19AM (#4027228)
Very useful, though it has been posted numerous times before.

http://hackerne.ws/item?id=2876612

Re:The Shapes of CSS by tfb on Saturday May 26, 2012 @10:48AM (#4027384)
It's certainly very cool, but is it really that useful? Or I could just be missing the bigger picture. I actually hope that's the case so I can learn something new today. But it just seems to me like making a png/gif image is much easier and more practical. I do love to see technology pushed to its limits though!

I guess one of the cooler applications of this shape making method would be the ability to transform one shape into another very smoothly with a relatively small filesize (as opposed to an animated gif).

Re:The Shapes of CSS by dmvaldman on Saturday May 26, 2012 @11:17AM (#4027459)
There are more benefits:

Costs nothing to change colors. This makes it great for iterating.

No bandwidth costs as CSS is rendered on the client.

Infinitely scalable in size. No rasterization.

Availability of other CSS functionality, like shadows, animation etc

Re:The Shapes of CSS by majormajor on Saturday May 26, 2012 @02:54PM (#4028030)
The last one is an issue, actually. The space invader one is the extreme case: it's already a shadow. And the border tricks for triangles are also shadow-resistant.
Re:The Shapes of CSS by coopdog on Saturday May 26, 2012 @09:25PM (#4028896)
I lost it at ying yang