Tool

Spanky Corners 1.1 beta

The SitePoint Corners Store

Generator

To use the generator select your preferred foreground color (hex), background color (hex), corner radius (pixels: 5-60) and hit 'Spank Me!'.

The generator will reload 'wearing' your selection while providing you 4 corner GIFs, the basic CSS and the HTML to obtain the effect.

Or if you're lazy, try these preset values.

Colors

Dimensions

Box Contents

Choose one or more header tags (e.g. h1, h2) that you will use to mark the top of each content box.

Code

The HTML:

Here is the HTML in it's simplest form:


<div class="rounded">

  <h4>Heading</h4>

	 <p>Lorem ipsum... </p>

</div> 
Your Images

Here are the corner images:

  • Top Left
  • Top Right
  • Bottom Left
  • Bottom Right

Here is the generated css [download the css file]:

/**
 * Spanky Corners -- CSS Rounded Corners by SitePoint
 *
 * Auto generated code
 * Details @ http://tools.sitepoint.com/spanky/
 * @version 1.1b
 */


body {
  background-color: #f6f6ff;
  color: #333333;
  font-size:62.5%; /* Explain @ www.clagnut.com/blog/348/ */
}

/* all curved boxes get the bottom-left corner */
div.rounded {
  background: #77aa34 url(bl_10_77aa34_f6f6ff.gif) no-repeat bottom left;
  color: #333333;
  position: relative;
  padding-top: 0;
  padding-bottom: 10px;
  margin: 1em 10px 0 0 ;
  height:100%
}

/* all elements in 'div.rounded' gets the B-R corner */
div.rounded * {
  background: #77aa34 url(br_10_77aa34_f6f6ff.gif) no-repeat bottom right;
  color: #333333;
  padding: 1em 2em 10px 0;
  margin: 0 0 -10px 10px;
  height:100%;
}

/* Scrub that B-R corner from all elements *2+* levels deep*/
div.rounded * * {
  padding: 0;
  margin: 0;
  background: none;
  color: #333333;
  height:auto
}

/* Set up some H's as 'box heads' with the T-R and T-L corners */
div.rounded h1, div.rounded h4 {
  color: #f6f6ff;
  background: #77aa34 url(tr_10_77aa34_f6f6ff.gif) no-repeat top right;
  display: list-item;
  list-style-image: url(tlc_10_77aa34_f6f6ff.gif);
  list-style-position: inside;
  list-style-type:none;
  padding: 0;
  margin: 0;
  position: relative;
}

div.rounded h1 {
  font-size: 3.2em;
}
div.rounded h4 {
  font-size: 2em;
}
IE Conditional Comments

Download the IE only style sheet, save them as rounded-ie.css and add the following conditional comments in the head of your document


<!--[if IE]>
<link type="text/css" rel="stylesheet" href="rounded-ie.css" media="screen" />
<![endif]-->

Spanky Corners is a work in progress, so if you have a suggestion or improvement, let us know.

Spanky Corners

What?

'Spanky Corners' is an experimental technique for using only CSS to produce 'round-cornered content boxes' with semantically pure markup. It does not require JavaScript to work

Why?

SpankyCorners has a number of advantages over alternative rounded corners methods.

  1. Spanky requires no extra HTML markup to act as 'CSS hooks'.
  2. Spanky doesn't rely on a set width box.
  3. Spanky doesn't require JavaScript.
  4. Spanky corners can have (practically) any radius with no significant increase to file size.
  5. Spanky requires only 4 small GIFs.
  6. We generate the required images for you while you wait!
News

We're always happy to hear any feedback/suggestions for Spanky via this blog entry.

Update: 8 May, 2006: Fixed a Firefox 1.0 render bug which was making the site look wacky. Fixed a mistake in the download code that stopped IE from rendering properly.

Update: 3 May, 2006: Solved the IE6 scaling problem. Scale to your heart's content. However it does sacrifice a little padding control on the headings in IE. Also made the whole kit'n'caboodle downloadable as a ZIP file (thanks to fine work by Lox).

Update: 28 April, 2006: A few changes. Most obviously we've moved the generator into a more 'SitePoint-like' setting. Spanky Corners now also zoom smoothly up and down in all browsers except IE6, where the top left corner shows a gap when the text is scaled up. Solutions are very welcome.

Update: 19 April, 2006: We had trouble getting IE6-7 to work with corner radii less than 17px (IE reserves that much space for it's bullets), but Matt Magain has come up with a nice solution. It does require IE's Conditional Comments at this stage.

Update: 15 April, 2006: Updated the way the images are generated and the code algorithms. Should work reliably in IE6-IE7 on most settings -- with the exception of very large or very small curves. However manual tinkering with the code should get virtually any setting to work.

Launch: 13 April, 2006 The Spanky Corners Generator doesn't yet work flawlessly in IE6 and IE7 (working on it right now) though the technique itself does. You're welcome to play with the generator as we work on it.

This idea was first demonstrated in the April 2006 edition (#20) of the SitePoint Design View.

NEW! - March 2006