News for hackers. Stuff that matters.
Re:CSS Rounded corners: 7 lines of code, without any images by makecheck on Tuesday May 27, 2008 @10:43PM (#201711)
At this point in time, it is far easier to just rely on CSS extensions well supported by Firefox and Safari, for instance:

-moz-border-radius-topleft: 0.4em; -webkit-border-top-left-radius: 0.4em; -moz-border-radius-topright: 0.4em; -webkit-border-top-right-radius: 0.4em; -moz-border-radius-bottomleft: 0.4em; -webkit-border-bottom-left-radius: 0.4em; -moz-border-radius-bottomright: 0.4em; -webkit-border-bottom-right-radius: 0.4em;

This doesn't mess up your HTML with divs, and degrades seamlessly to "not rounded corners" in any other browser.

Re:CSS Rounded corners: 7 lines of code, without any images by GHFigs on Tuesday May 27, 2008 @11:36PM (#201749)
Amen! Although to make the point better, you can just use the shorthand: -moz-border-radius: 0.4em; -webkit-border-radius: 0.4em;

Seven lines of CSS and fifteen of HTML per box is bullshit when you can do the same thing in a standard and semantically better way in the space of a Twitter message. I can hardly believe people still put so much effort into IE-specific workarounds for purely decorative effects.

Re:CSS Rounded corners: 7 lines of code, without any images by zenspider on Wednesday May 28, 2008 @02:54AM (#201845)
I don't disagree with using the extensions...

... but ...

if you're actually writing 15 lines per box, you're doing it wrong.

refactor refactor refactor

Re:CSS Rounded corners: 7 lines of code, without any images by GHFigs on Wednesday May 28, 2008 @09:35AM (#202045)
There is no right way to do something this stupid.
Re:CSS Rounded corners: 7 lines of code, without any images by henryw on Tuesday May 27, 2008 @10:46PM (#201715)
most people, excluding hackers of course, probably use ie.
Re:CSS Rounded corners: 7 lines of code, without any images by jauco on Wednesday May 28, 2008 @03:28AM (#201868)
so let's give them more reasons to switch :-)
Re:CSS Rounded corners: 7 lines of code, without any images by elai on Wednesday May 28, 2008 @10:15PM (#202878)
Actually nowadays, firefox is 1/5th of the browser market. It's a significant chunk of the market.
Re:CSS Rounded corners: 7 lines of code, without any images by witten on Wednesday May 28, 2008 @05:30AM (#201918)
At least in Firefox 2, corners made with border-radius are not anti-aliased and look pretty horrible. (Firefox 3 may fix this.)
Re:CSS Rounded corners: 7 lines of code, without any images by ajross on Wednesday May 28, 2008 @12:10PM (#202258)
This technique doesn't antialias the corners either. It just draws tiny background rectangles with careful margins. But it's pretty clever, IMHO. And a few lines of jquery could automatically add the extra markup at load time.
Re:CSS Rounded corners: 7 lines of code, without any images by philh on Wednesday May 28, 2008 @03:27AM (#201867)
IIRC, opera also supports this (without a -*- prefix). I think for the individual corners you use -topleft instead of -top-left-.
Re:CSS Rounded corners: 7 lines of code, without any images by zach on Wednesday May 28, 2008 @01:31AM (#201807)
This is what YouTube used to style their box headers until maybe a year and a half ago.

Note that if you're using it to make a vertically compact title box, you'll have to do even more CSS funny business. That's because the rounded-corner header is a separate entity from the box below it, so you need to tweak the text to appear above its normal position in the box.

Confession time. Yes, I know because I myself admired YouTube's rounded corners enough to peek at their CSS and implement this technique as well. Hugs, not drugs, kids.

Re:CSS Rounded corners: 7 lines of code, without any images by oneplusone on Tuesday May 27, 2008 @10:16PM (#201691)
We have been using this technique on the Freshbooks login pages for a while now. (example: http://reason.freshbooks.com) It enables our customers to customize their account colors while maintaining the elegance of rounded corners.
Re:CSS Rounded corners: 7 lines of code, without any images by geuis on Wednesday May 28, 2008 @12:05PM (#202254)
you aren't serious are you? Please tell me you website is your own pet project and that you didnt build it for a paying client or your employer
Re:CSS Rounded corners: 7 lines of code, without any images by ajross on Wednesday May 28, 2008 @12:18PM (#202265)
Please. Check the absolutist pedantry at the door. If the technique works and doesn't affect the content management process (which, remember, is the real reason that people want non-semantic markup out of the HTML -- it's so that there's a single place to look for the semantic stuff) then by all means go for it. With just a few lines of jquery you could automate this process based on a single class tag for the "rounded corner" divs or whatnot, and everyone wins.

I'm not completely sold that this is easier than image mangement (it probably is for developers who fear graphics work, less so for designers who fear code hackery), but it's awfully clever to my eyes.

Re:CSS Rounded corners: 7 lines of code, without any images by scooter53080 on Tuesday May 27, 2008 @09:33PM (#201656)
don't know who came up with this first, but it looks strikingly similar to 'nifty corners': http://www.html.it/articoli/nifty/index.html

Here is a technique I have used before to add a 'snazzy border': http://www.cssplay.co.uk/boxes/snazzy.html

Re:CSS Rounded corners: 7 lines of code, without any images by rrwhite on Tuesday May 27, 2008 @09:39PM (#201661)
Yeah it is essentially the same technique that all those JS rounding libraries use. The nice thing about the libraries is that you don't have to see all those extra horseshit DOM elements you need to make this work.

Either way you're going to make a standarista cry.

Re:CSS Rounded corners: 7 lines of code, without any images by quickpost on Tuesday May 27, 2008 @09:15PM (#201646)
Cool. How many browsers does it work in?
Re:CSS Rounded corners: 7 lines of code, without any images by nreece on Tuesday May 27, 2008 @09:30PM (#201655)
Did a quick test. Works in IE6 and FF2. Anyone willing to give it a try in IE7, Opera, and Safari?
Re:CSS Rounded corners: 7 lines of code, without any images by michaelr on Tuesday May 27, 2008 @10:04PM (#201684)
IE7 seemingly handles it as well.
Re:CSS Rounded corners: 7 lines of code, without any images by rwebb on Tuesday May 27, 2008 @09:42PM (#201664)
works in opera and safari.
Re:CSS Rounded corners: 7 lines of code, without any images by pmjordan on Wednesday May 28, 2008 @05:05AM (#201908)
Konqueror too!
Re:CSS Rounded corners: 7 lines of code, without any images by geuis on Tuesday May 27, 2008 @09:37PM (#201659)
why would any developer who didnt want to lose their job use this? There are lots of things you can do that you shouldn't. So what I can do with one background image and 2-3 divs and look good, you can do with a series of bold tags to look bad. Sorry to be critical, but this is not the quality of content I have come to expect from HN. Digg maybe.
Re:CSS Rounded corners: 7 lines of code, without any images by ambition on Wednesday May 28, 2008 @12:05AM (#201761)
I've never hit a CSS rounded corners solution that met all my requirements:

* No image files (Extra HTTP requests/inflexible to colour changes)

* No extra markup (All the benefits of a clean DOM)

* Cross-browser without relying on parsing bugs (Supporting user choice is good)

* No pixel-based measurements (Visual designs should scale to different browser text sizes and screen resolutions)

Given that, any solution will involve some trade-offs. To me, some non-semantic HTML is a reasonable sacrifice since it is transparent to most users.

Re:CSS Rounded corners: 7 lines of code, without any images by nreece on Wednesday May 28, 2008 @03:23AM (#201864)
Its code hacking, a part of what hackers do. If it was actually Digg material, it would have been on the Digg frontpage by now.
Re:CSS Rounded corners: 7 lines of code, without any images by henryw on Tuesday May 27, 2008 @10:44PM (#201712)
because hackers like to do things with less work. creating images means work. the code does look long though. it should probably be abstracted into a server-side view helper function.
Re:CSS Rounded corners: 7 lines of code, without any images by tdavis on Tuesday May 27, 2008 @11:21PM (#201741)
Less work in this case = horrible results. You're ruining the semantics of the DOM to use a crappy method for creating rounded corners. Want to create a fluid box with rounded corners and even less work? Use Javascript. You're not writing crappy HTML and it's even less work; just tag the <div /> with a class.

If the quality of the implementation weren't bad enough, this method isn't even new.