Home >Web Front-end >CSS Tutorial >How Can I Create Rounded Corners for Inner Boxes and Borders?
The goal is to create a box with rounded corners and a border that also has rounded borders. The background-clip property can be used to achieve the rounded corners for the border. However, the inner box remains rectangular.
To round the corners of the inner box, the border-radius property can be used. The inner border radius is calculated as the difference between the outer border radius and the border width. Therefore, the inner border radius becomes:
inner border radius = outer border radius - border width
If the border width is greater than the border radius, the inner border radius becomes negative, resulting in inverted corners. Therefore, the border width should be considered when calculating the inner border radius.
In the provided code, the border width is 5px and the outer border radius is 10px. Using the formula above, the inner border radius becomes:
inner border radius = 10px - 5px = 5px
The modified CSS becomes:
.radius-all { border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; } .template-bg { background: #FFF; } .template-border { border: 5px solid rgba(255, 255, 255, 0.2); }
The above is the detailed content of How Can I Create Rounded Corners for Inner Boxes and Borders?. For more information, please follow other related articles on the PHP Chinese website!