温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CSS3如何制作圆角边框

发布时间:2026-08-30 12:02:51 来源:亿速云 阅读:84 作者:小樊 栏目:编程语言

在 CSS3 中,制作圆角边框最常用的方法是使用 border-radius 属性。下面按常见用法给你详细说明。


一、基本用法

1️⃣ 四个角统一圆角

.box {
  width: 200px;
  height: 100px;
  border: 2px solid #333;
  border-radius: 10px;
}

✅ 效果:四个角都变成 10px 的圆角


二、分别设置四个角

2️⃣ 单独设置每个角

.box {
  border-radius: 10px 20px 30px 40px;
}

顺序为:

左上 → 右上 → 右下 → 左下

3️⃣ 使用具体角属性

.box {
  border-top-left-radius: 10px;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 30px;
  border-bottom-left-radius: 40px;
}

三、常见圆角效果

4️⃣ 圆形(宽高相同)

.circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

5️⃣ 椭圆(宽高不同)

.ellipse {
  width: 200px;
  height: 100px;
  border-radius: 50%;
}

6️⃣ 胶囊按钮(常见于按钮)

.btn {
  padding: 10px 30px;
  border-radius: 999px;
}

四、椭圆型圆角(水平 / 垂直)

.box {
  border-radius: 20px / 10px;
}

解释:

  • 水平半径:20px
  • 垂直半径:10px

五、配合其他属性使用

.card {
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,.1);
}

六、兼容性说明

border-radiusIE9+ 开始支持
✅ 现代浏览器(Chrome / Firefox / Edge / Safari)完全支持
❌ 不需要前缀(已过时)


七、小技巧总结

场景 写法
普通圆角 border-radius: 8px;
圆形 border-radius: 50%;
胶囊按钮 border-radius: 999px;
只圆上方 border-radius: 10px 10px 0 0;

如果你需要 配合渐变边框、图片圆角、或动画效果,我也可以继续帮你写示例。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI