Rounded corners in IE

Look nice don't they, these rounded corners?

And no, no images. Only CSS. Not even background-images. Just CSS.
I wish I thought of it. But I didn't, Hedger did. He created the rounded corners.
Then, RobinAnn thought of a method to make rounded borders.

Let's step throught it.
Oh, by the way, you'll need IE to see the various steps in action as they are hidden for other browsers.

First we need a container of some sort.
<DIV class="RB">
  Some content
</DIV>

And some style.
.RB {
  border:2px #aaaaaa solid;
  background-color:#eeeeee;
  color:#000000;
  -moz-border-radius:25px; /* Borders for Gecko browsers. */
  width:75%;
  margin-top:25px;
  margin-bottom:25px;
}

Then we add an inner container..
<DIV class="RB">
  <DIV class="RC">
    Some content
  </DIV>
</DIV>

And some style.
.RB {
  .....
  padding-top:25px     /* To make room (vertical) for the corners. */
  padding-bottom:25px; /* Otherwise we'd run into trouble with scrollbars. */
}
.RC {
  padding-left:25px;
  padding-right:25px;
  min-height:100px;
  max-height:250px;
  overflow:auto;
  font:0.75em verdana;
}

And something extra for IE
/* IE hack to mimick min-height & max-height */
.RC {
  height:expression( (((250-offsetHeight)>0)?(((offsetHeight-100)>0)?'none':100):250) );
}

Have you ever taken a closer look at the border-style dotted? (In IE these will be round.)

 

Or, an even closer look.

 

And if we clip it.

 
 

Or if we clip 4 of them.

 
 
 
 
 

By the by, the style for the first one (top left) is:
  border:50px #000000 dotted;
  width:150px;
  height:150px;
  clip:rect(0px 25px 25px 0px);
  font-size:1px;
  position:absolute;

Lets remove the border and darken the backgound for a moment.
Done, now for rounded corners.

We add 4 spans for the corners.
<DIV class="RB">
  <SPAN class="RC-1"></SPAN>
  <SPAN class="RC-2"></SPAN>
  <SPAN class="RC-3"></SPAN>
  <SPAN class="RC-4"></SPAN>
  <DIV class="RC">
    Some content
  </DIV>
</DIV>

And style
.RC-1, .RC-2, .RC-3, .RC-4 {
  z-index:-18;
  border:#eeeeee 50px dotted;
  font-size:1px;
  width:150px;
  height:150px;
  position:absolute;
}
.RC-1 { top:   0px; left:  0px; clip:rect(  0px  25px  25px   0px); }
.RC-2 { top:   0px; right:-1px; clip:rect(  0px 150px  25px 125px); }
.RC-3 { bottom:0px; right:-1px; clip:rect(125px 150px 150px 125px); }
.RC-4 { bottom:0px; left:  0px; clip:rect(125px  25px 150px   0px); }
}

As you've probably noticed. we need some backgrounds for the corners.

We add 4 spans for backgrounds.
<DIV class="RB">
  <SPAN class="RC-1-bg"></SPAN>
  <SPAN class="RC-2-bg"></SPAN>
  <SPAN class="RC-3-bg"></SPAN>
  <SPAN class="RC-4-bg"></SPAN>

  <SPAN class="RC-1"></SPAN>
  <SPAN class="RC-2"></SPAN>
  <SPAN class="RC-3"></SPAN>
  <SPAN class="RC-4"></SPAN>
  <DIV class="RC">
    Some content
  </DIV>
</DIV>

And style.
.RC-1-bg, .RC-2-bg, .RC-3-bg, .RC-4-bg {
  z-index:-20;
  background-color:white;
  font-size:0px;
  width:25px;
  height:25px;
  position:absolute;
}
.RC-1-bg { top:   0px; left:  0px; }
.RC-2-bg { top:   0px; right:-1px; }
.RC-3-bg { bottom:0px; right:-1px; }
.RC-4-bg { bottom:0px; left:  0px; }

Background-color back to the original. Looks about right, doesn't it?

Re-adding the border. Ugh, ghastly.

Lets change the position of the backgrounds.

.RC-1-bg { top:   -2px; left: -2px; }
.RC-2-bg { top:   -2px; right:-3px; }
.RC-3-bg { bottom:-2px; right:-3px; }
.RC-4-bg { bottom:-2px; left: -2px; }

A bit better.

We add 4 spans for the corner borders. We place these between the background and the corder.
<DIV class="RB">
  <SPAN class="RC-1-bg"></SPAN>
  <SPAN class="RC-2-bg"></SPAN>
  <SPAN class="RC-3-bg"></SPAN>
  <SPAN class="RC-4-bg"></SPAN>
  <SPAN class="RC-1-brd"></SPAN>
  <SPAN class="RC-2-brd"></SPAN>
  <SPAN class="RC-3-brd"></SPAN>
  <SPAN class="RC-4-brd"></SPAN>

  <SPAN class="RC-1"></SPAN>
  <SPAN class="RC-2"></SPAN>
  <SPAN class="RC-3"></SPAN>
  <SPAN class="RC-4"></SPAN>
  <DIV class="RC">
    Some content
  </DIV>
</DIV>

And style.
.RC-1-brd, .RC-2-brd, .RC-3-brd, .RC-4-brd {
  z-index:-19;
  border:#eeeeee 50px dotted;
  font-size:1px;
  width:150px;
  height:150px;
  position:absolute;
}
.RC-1-brd { top:   0px; left:  0px; clip:rect(  0px  25px  25px   0px); }
.RC-2-brd { top:   0px; right:-1px; clip:rect(  0px 150px  25px 125px); }
.RC-3-brd { bottom:0px; right:-1px; clip:rect(125px 150px 150px 125px); }
.RC-4-brd { bottom:0px; left:  0px; clip:rect(125px  25px 150px   0px); }

Of course we'll need to change the sizes of the corners to reflect the inside of the corner border.
.RC-1, .RC-2, .RC-3, .RC-4 {
  z-index:-18;
  border:#eeeeee 46px dotted;
  font-size:1px;
  width:138px;
  height:138px;
  position:absolute;
}
.RC-1 { top:   0px; left:  0px; clip:rect(  0px  23px  23px   0px); }
.RC-2 { top:   0px; right:-1px; clip:rect(  0px 138px  23px 115px); }
.RC-3 { bottom:0px; right:-1px; clip:rect(115px 138px 138px 115px); }
.RC-4 { bottom:0px; left:  0px; clip:rect(115px  23px 138px   0px); }

An example

Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

1914 translation by H. Rackham

"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"

Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."

1914 translation by H. Rackham

"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."

FAQ

In the style definitions for .RC-1-brd and .RC-1, why these values for width, height and the border?

I wanted corners with a radius of 25 pixels. However, you'll need the diameter to get the value for the border-width. Hence the 50px border-width.

The width of the element should be at least 3 times the border-width. (a dot, a space and another dot.) 5.230.421 pixels would work equally well as element width.
But 150px (3 * 50px) is easier to calculate.
The height of the element doesn't matter, I could have left that one blank. But once again, using 3 times the border-width makes for easier calculation.

46 is a calculated dimension. A 25px radius - a 2px border is an inside radius of 23px. Hence the 46px border-width and the 138px width and height.

What then, are the values in the clip:rect(); property?

For an explanation of the clip:rect(); property I defer to w3.org.
0, 25 and 150 speak for themselfs. 125 is the width (150px) - the radius (25px).
Similar for 0, 23 and 138. 115 is the width - the inner radius.

And the top, left, right and bottom properties?

2 is the border width. Hence -2px to place the elements on the outside edge of the border.
-3 is the same, 2px to get to outside border edge and a 1px compensation to remove the 1px line IE tends to show. (Try it with -2 to see what I mean)

I don't want the max-height and the scrollbars.

Simple, Remove the max-height and overflow properties from the definition. And remove the maximum height part of the expression in the height property of the IE hack.

Please explain the IE hack for min-height and max-height.

That is not within the scope of this document. Read the original thread (or ask there).

To whom do I send shiploads of money if I want to use these methods?

You could send it to me, but Hedger & RobinAnn are more deserving.