The borderRadius
property gets and sets the
shorthand property for the four border-*-Radius properties.
borderRadius |
Yes | 10.0 | Yes | Yes | Yes |
Return the borderRadius property:
var v = object.style.borderRadius
Set the borderRadius property:
object.style.borderRadius=1-4 length|% / 1-4 length|%|initial|inherit
The borderRadius uses the following rules to deal with the missing values.
Value | Description |
---|---|
length | Set the size in length unit. Default value is 0 |
% | Set the size of the corners in percent |
initial | Set to default value |
inherit | Inherit from parent element. |
Default Value: | 0 |
---|---|
Return Value: | A string representing the border-radius property |
CSS Version | CSS3 |
The following code shows how to add rounded borders to a div element.
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {<!--from w w w . j a v a 2 s. co m-->
border: 1px solid black;
width: 300px;
height: 300px;
}
</style>
</head>
<body>
<button onclick="myFunction()">test</button>
<div id="myDIV">Hello</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.borderRadius = "25px";
}
</script>
</body>
</html>
The code above is rendered as follows: