跳转到帖子
在手机APP中查看

一个更好的浏览方法。了解更多

OKCCN - XenForo & IPS Plugin Marketplace

主屏幕上的全屏APP,带有推送通知、徽章等。

在iOS和iPadOS上安装此APP
  1. 在Safari中轻敲分享图标
  2. 滚动菜单并轻敲添加到主屏幕
  3. 轻敲右上角的添加按钮。
在安卓上安装此APP
  1. 轻敲浏览器右上角的三个点菜单 (⋮) 。
  2. 轻敲添加到主屏幕安装APP
  3. 轻敲安装进行确认。
  • 选择语言

CSS Rounded Corners

推荐的帖子

  • 行政经理

CSS Rounded Corners


CSS Rounded Corners

The CSS border-radius property is used to create rounded corners for elements.


CSS border-radius Property

The border-radius property defines the radius of an element's corners.

This property can be applied to all elements with a background-color, a border, or a background-image.

Here are three examples:

1. Rounded corners for an element with a background color:

Rounded corners!

2. Rounded corners for an element with a border:

Rounded corners!

3. Rounded corners for an element with a background image:

Rounded corners!

Here is the code:

Example

#div1 {
  border-radius: 25px;
  background-color: #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}

#div2 {
  border-radius: 25px;
  border: 2px solid #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}

#div3 {
  border-radius: 25px;
  background-image: url(paper.gif);
  background-position: left top;
  background-repeat: repeat;
  padding: 20px;
  width: 200px;
  height: 150px;
}
Try it Yourself »

Tip: The border-radius property is actually a shorthand property for the border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius properties.



CSS border-radius - Specify Each Corner

The border-radius property can have from one to four values. Here are the rules:

Four values - border-radius: 15px 50px 30px 5px; (first value applies to top-left corner, second value applies to top-right corner, third value applies to bottom-right corner, and fourth value applies to bottom-left corner): 

Three values - border-radius: 15px 50px 30px; (first value applies to top-left corner, second value applies to top-right and bottom-left corners, and third value applies to bottom-right corner):

Two values - border-radius: 15px 50px; (first value applies to top-left and bottom-right corners, and the second value applies to top-right and bottom-left corners):

One value - border-radius: 15px; (the value applies to all four corners, which are rounded equally:

Here is the code:

Example

#div1 {
  border-radius: 15px 50px 30px 5px; /* four values */
 background: #04AA6D;
  width: 200px;
  height: 150px;
}

#div2 {
  border-radius: 15px 50px 30px; /* three values */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}

#div3 {
  border-radius: 15px 50px; /* two values */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}

#div4 {
  border-radius: 15px; /* one value */
  background: #04AA6D;
  width: 200px;
  height: 150px;
}
Try it Yourself »

CSS Elliptical and Circular Shapes

To create elliptical corners, you must specify two values for each radius, separated by a slash /. The first value defines the horizontal radius, and the second value defines the vertical radius.

To create a oval shape (for a rectangular element), or to create a circular shape (for a square element) set border-radius to 50%. 

Example

Create elliptical, oval and circular shapes:

#div1 {
  border-radius: 70px / 30px;
  background: #04AA6D;
  width: 200px;
  height: 150px;
}

#div2 {
  border-radius: 15px / 50px;
  background: #04AA6D;
  width: 200px;
  height: 150px;
}

#div3 {
  border-radius: 50%;
  background: #04AA6D;
  width: 200px;
  height: 150px;
}

#div4 {
border-radius: 50%;
background: #04AA6D;
width: 200px;
height: 200px;
}
Try it Yourself »


CSS Rounded Corners Properties

Property Description
border-radius A shorthand property for setting all the four border-*-*-radius properties
border-top-left-radius Defines the shape of the border of the top-left corner
border-top-right-radius Defines the shape of the border of the top-right corner
border-bottom-right-radius Defines the shape of the border of the bottom-right corner
border-bottom-left-radius Defines the shape of the border of the bottom-left corner

参与讨论

你可立刻发布并稍后注册。 如果你有帐户,立刻登录发布帖子。

游客
回帖…

帐户

导航

搜索

搜索

配置浏览器推送通知

Chrome (安卓)
  1. 轻敲地址栏旁的锁形图标。
  2. 轻敲权限 → 通知。
  3. 调整你的偏好。
Chrome (台式电脑)
  1. 点击地址栏中的挂锁图标。
  2. 选择网站设置。
  3. 找到通知选项并调整你的偏好。