border-radius
Description
The border-radius
property is a shorthand property for setting
the border radius properties in four corners.
We can use border-radius
to create round corners.
Item | Value |
---|---|
Initial value | 0 |
Inherited | no. |
Version | CSS3 |
JavaScript syntax | object.style.borderRadius="5px" |
Syntax and Property Values
border-radius:length|% length|% length|% length|% /
length|% length|% length|% length|%
The property values are listed in the following table.
Value | Description |
---|---|
length | set the length for radius |
% | set percentage size for radius |
border-radius:2em;
is equivalent to:
border-top-left-radius:2em;
border-top-right-radius:2em;
border-bottom-right-radius:2em;
border-bottom-left-radius:2em;
border-radius: 2em 1em 3em / 0.4em 3em;
is equivalent to:
border-top-left-radius: 2em 0.4em;
border-top-right-radius: 1em 3em;
border-bottom-right-radius: 3em 0.4em;
border-bottom-left-radius: 1em 3em;
Example
<!DOCTYPE html>
<html>
<head>
<style>
div<!--from www. j a va 2 s . c o m-->
{
border:2px solid red;
padding:10px 40px;
background:#eee;
width:300px;
border-radius:25px;
}
</style>
</head>
<body>
<div>Rounded corners.</div>
</body>
</html>
The code above generates the following result.