· code · 2 min read
Pure CSS rounded corners without images and javascript
Ever wonder how to make round corners with pure css without using Javascript and Images. Here is how to do it.
In this article I will show you how to make a rounded corner boxes without using images or javascript. We will use pure CSS2 only. However, some browsers support border radius property of CSS3.
This trick will apply to all browsers including IE6 which is know as headache for web developers.
Now you can make rounded corders using pure CSS that is consistent across browsers.
UPDATE: For bigger radius, increase number or span tags below and above with different class and increase margin to its css like this:
For more radius:
HTML
<div class="container">
<span class="round\_span7"></span>
<span class="round\_span6"></span>
<span class="round\_span5"></span>
<span class="round\_span4"></span>
<span class="round\_span3"></span>
<span class="round\_span2"></span>
<span class="round\_span1"></span>
<div class="content">
<!-- Content goes here -->
My name is Bond
<br />
James Bond
</div>
<span class="round\_span1"></span>
<span class="round\_span2"></span>
<span class="round\_span3"></span>
<span class="round\_span4"></span>
<span class="round\_span5"></span>
<span class="round\_span6"></span>
<span class="round\_span7"></span>
</div>
CSS
.container {
display: block;
}
.content {
background: #ccc;
}
.round\_span7 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 7px;
}
.round\_span6 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 6px;
}
.round\_span5 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 5px;
}
.round\_span4 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 4px;
}
.round\_span3 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 3px;
}
.round\_span2 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 2px;
}
.round\_span1 {
background: #ccc;
display: block;
line-height: 1px;
overflow: hidden;
height: 1px;
margin: 0 1px;
}