When using CSS3 border-radius
property to create rounded corners how would one keep the content (text, images, etc.) from appearing over the top of the corner?
Example:
Might be hard to tell with this but I hope you guys understand the question.
要将内容保留在框内,您可以使用padding
属性:
.box {
width: 400px;
height: 250px;
background-color: gold;
border-radius: 20px;
padding: 5px; /* or */
/* padding-left: 10px */
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
box-sizing: border-box;
用于计算元素的宽度和高度,包括填充和可能的边框。
这是JSBin 演示