Check out an example of text only rounded box corners with CSS.
The solution was largely inspired by Nifty Corners. However, Nifty Corners use a couple of extra tags that we don't need (this example uses one wrapping container less). Also, no Javascript is used here. Anyway, it should be a good addition to other tutorials on this site, so why not.
The HTML markup is pretty simple:
<div class="container"> <div class="five"></div> <div class="four"></div> <div class="three"></div> <div class="two"></div> <div class="one"></div> <div class="content"> Lorem ipsum dolor sit amet.. </div> <div class="one"></div> <div class="two"></div> <div class="three"></div> <div class="four"></div> <div class="five"></div> </div>
As is CSS coding:
.container {width:10em;}
.one, .two, .three, .four, .five { height:1px;
background:skyblue;}
.five {margin:0 5px;}
.four {margin:0 3px;}
.three {margin:0 2px;}
.two {margin:0 1px;}
.one {margin:0 1px;}
.content {padding:5px;background:skyblue;}
See the example.
Here is how it all was created:
This solution works best in all web standards compliant browsers. IE shows the corners slightly differently (check out how this example looks), so here is an example specifically for IE.
For IE, in addition to height:1px we specify font-size:1px to actually fix the height of our "corners". Also, we adjust the margins of the top two and bottom two blocks in order to display the corners more evenly.
That is, you can put the following code in your IE hacks stylesheet or setup any of the examples on your site (probably the IE one) to be visible in all browsers.
.one, .two, .three, .four, .five {font-size:1px;}
.five {margin:0 6px;}
.four {margin:0 4px;}
Supposedly, one can use the IE version for all browsers to avoid style sheet switching or applying hacks.
As much as the author of this tutorial adores flexible sizes (em, pt, %, etc), using pixels is easier here. Switching to points (pt) will require additional adjustment of the code.
Want rounded borders without a background?
Learn more:
Though it is important for people to find the information quickly, they also enjoy finding it easily.
Check out the recently added articles: