Home >Web Front-end >CSS Tutorial >How to achieve rounded borders with CSS

How to achieve rounded borders with CSS

不言
不言Original
2018-11-16 13:47:334068browse

CSS to achieve rounded borders requires the use of the border-radius property in CSS. Let’s take a look at the details of CSS to implement rounded borders.

Let’s take a look at the implementation code of a border without rounded corners

<div style="border:solid 4px #808080;">这是一个框架</div>

The effect is as follows:

How to achieve rounded borders with CSS

Let’s do it next Let’s look specifically at the code that uses the border-radius attribute in CSS to implement rounded borders.

Let’s first look at the syntax format of the border-radius attribute:

brder-radius:(左上水平半径)(右上水平半径)(右下水平半径)(左下水平半径)/(左上垂直半径)(右上垂直半径)(右下垂直半径)(左下垂直半径);

If / is omitted, it is assumed to be horizontal Have the same radius in both direction and vertical direction.

brder-radius:(左上半径)(右上半径)(右下半径)(左下半径);

Code example 1:

<div style="height:75px; padding-top:25px; border:solid 4px #808080;
  border-radius: 25px 25px 25px 25px / 25px 25px 25px 25px;">这是一个圆角边框</div>

The effect is as follows:

How to achieve rounded borders with CSS

Code example 2

<div style="height:75px; padding-top:25px; border:solid 4px #808080;
  border-radius: 100px 100px 1005px 1005px / 25px 25px 25px 25px;">圆角边框</div>

The effect As follows:

How to achieve rounded borders with CSS

Code example 3

<div style="height:75px; padding-top:25px; padding-left:16px; border:solid 4px #808080;
  border-radius: 50px 20px 20px 20px;">圆角边框</div>

The effect is as follows:

How to achieve rounded borders with CSS

Specify corner radius individually

border-top-left-radius

border-top-righr-radius

border-bottom-left-radius

border-bottom-right-radius

You can also specify the radius of each corner individually. The format is

border-top-left-radius (角的半径)

or

border-top-left-radius (角的水平半径) (角的垂直半径)

The above is the detailed content of How to achieve rounded borders with CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn