Wednesday, August 1, 2012

Cross browser code for rounded corner in css

Cross browser code for rounded corner :


      Now a days , designing a border with rounded corner is very familiar. We can achieve this functionality by using css. But when we write css code for getting rounded corner border, it will work in some browsers and not work in some other browsers. The following css code will work for all browsers including Internet Explorer.  But if we want rounded corner in IE we need an extra file, that is PIE.htc file. You can download this file from the following source.

Download Here

Note: After downloading, Extract the file.

          Now copy the following code as it is, and save with anyname.html .

Code:



<!Doctype html>
<html>
<head>
<title>Rounded Corner</title>
<style type="text/css">
.rounded_corner {
border: 1px solid #696;
padding: 10px 0;
text-align: center; 
width:300px;
height:300px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
background: #188BC0;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#25A6E1), to(#188BC0));
background: -webkit-linear-gradient(#25A6E1, #188BC0);
background: -moz-linear-gradient(#25A6E1, #188BC0);
background: -ms-linear-gradient(#25A6E1, #188BC0);
background: -o-linear-gradient(#25A6E1, #188BC0);
background: linear-gradient(#25A6E1,#188BC0);
-pie-background: linear-gradient(#25A6E1, #188BC0);
color: #fff;
font-family: 'Helvetica Neue' ,sans-serif;
font-size: 17px;
behavior: url(PIE.htc);
}
</style>
</head>
<body>
<div class="rounded_corner"></div>
</body>
</html>




Note: you have to give exact path of PIE.htc file in behavior: url(PIE.htc).

           After running the html file you will see the following rounded corner box. This will work for all browsers.


Output:


             If you want more rounded corner just change the values of  border-radius: 15px, -moz-border-radius: 15px, -webkit-border-radius: 15px values to some ther values.