How to set the border in css? Many times when developing the front-end of a web page, in order to make the things on the web page look more comfortable, we may need to set some rounded borders such as buttons. So, how do we set rounded borders? This article will introduce to you how to set rounded borders in CSS.
The most common and simplest way to set a rounded border in css is to use the border-radius attribute.
CSS rounded corners only need to set one property: border-radius (meaning "border radius"). You provide a value for this property to set the radii of all four corners at the same time. All legal CSS measurements can be used: em, ex, pt, px, percentage, etc.
Let’s take a look at a css code example to set a rounded border:
<!DOCTYPE html> <html> <head> <style> div { text-align:center; border:2px solid #a1a1a1; padding:80px 40px; background:pink; width:150px; border-radius:25px; -moz-border-radius:25px; /* 老的 Firefox */ } </style> </head> <body> <div>圆角边框</div> </body> </html>
The effect is as follows:
border-radius can be set to 1 at the same time to 4 values.
If you set a value, it means that all four fillets use this value.
css rounded border code: border-radius: 15px;
##If two values are set , indicating that the upper left corner and lower right corner use the first value, the upper right and lower left corners use the second value. css rounded border code: border-radius: 15px 5px; If three values are set, it means that the first value is used in the upper left corner, and the upper right corner is The second value is used for the corner and lower left corner, and the third value is used for the lower right corner. css rounded border code: border-radius: 15px 5px 25px; If set four values, then in order Corresponds to the upper left corner, upper right corner, lower right corner, and lower left corner (clockwise order). css rounded border code: border-radius: 15px 5px 25px 0px; border-radius can also use slashes to set the second set of values. The first set of values represents the horizontal radius, and the second set of values represents the vertical radius. The second set of values can also set 1 to 4 values at the same time, and the application rules are the same as the first set of values. In addition to setting four rounded corners at the same time, you can also set each corner individually. Corresponding to the four corners, CSS3 provides four separate properties: border-top-left-radiusborder-top-right-radius
border-bottom-right-radius
border -bottom-left-radius
css manual.
The above is the detailed content of How to set rounded borders in css? How to set rounded borders in css (image and text). For more information, please follow other related articles on the PHP Chinese website!