在 CSS3 中,实现圆角边框主要使用 border-radius 属性。下面从基础到进阶给你说明。
.box {
width: 200px;
height: 100px;
border: 2px solid #333;
border-radius: 10px;
}
表示四个角的圆角半径都是 10px。
顺序:左上 → 右上 → 右下 → 左下
.box {
border-radius: 10px 20px 30px 40px;
}
.box {
border-radius: 20px / 10px;
}
表示水平半径 20px,垂直半径 10px。
.box {
border-top-left-radius: 10px;
border-top-right-radius: 20px;
border-bottom-right-radius: 30px;
border-bottom-left-radius: 40px;
}
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
}
.pill {
height: 40px;
padding: 0 20px;
border-radius: 20px;
}
.semi {
width: 100px;
height: 50px;
border-radius: 50px 50px 0 0;
}
border-radius 对 块级元素和行内块元素 都生效如果你有具体场景(如卡片、头像、对话框),我可以给你更贴合的示例。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。