Home Web Front-end HTML Tutorial CSS3 study notes border-radius_html/css_WEB-ITnose

CSS3 study notes border-radius_html/css_WEB-ITnose

Jun 24, 2016 pm 12:33 PM

I think CSS3 is very good, I have seen it a little bit and tried some attributes. For myself, I don’t have the courage to say that I have learned CSS3. I feel that any matter that seems small to me can only be judged from my own perspective. Even "simple" HTML is worth studying in my opinion. Only by maintaining a humble attitude at all times can we see further and move more steadily.

I would like to thank the website here:

w3cplus, W3School, W3C and other online tutorials, blogs, etc. (there are many more so I won’t list them one by one). I started from these I started to come into contact with the legendary CSS3 and HTML5, and my own study notes will naturally learn from them.


Today we introduce the rounded corners of CSS3: border-radius

Think back to those days... Making rounded corners based on CSS2 can be considered a skill! ! Various pictures and various nestings (introduced in "Mastering CSS?? Advanced Web Standard Solution", I won't go into the process here, you can find it by searching online. In short: I thought it was very high-end before I used CSS3. After using CSS3, I don’t want to see it again)

But since the emergence of CSS3’s rounded corner attribute border-radius, the majority of front-end engineers can save a lot of troubles, not only reduce the workload, but also improve Website performance. It's a pity that the noble and low-end version of IE does not support most of the properties of CSS3...or almost none of them. Although great people have written many compatibility solutions for IE, I do not recommend them. Rounded corners are often just more visually elegant and basically do not affect user use.

If you can’t see the rounded corners, it’s only because you are friends with a lower version of IE! ! ! !

Okay, now let’s formally introduce this noble attribute

Usage of border-radius:

属性名 border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-top-left-radius,border-radius
属性值 长度(eg:10px)
初始值 0
可否继承 不能继承

The size of the value in border-radius determines the arc Shape, the arc of each corner is actually 1/4 arc of the circle drawn with the value set at this corner as the radius.

For example: when border-radius has only one value

Set border-radius: 50px;

CSS code:

 1: .test{
Copy after login
 2:     width:200px;
Copy after login
 3:     height:200px;
Copy after login
 4:     background:#368;
Copy after login
 5:     margin:80px auto;/*为了使元素居中,没有别的意思*/
Copy after login
 6:     -webkit-border-radius:50px;
Copy after login
 7:     -moz-border-radius:50px;
Copy after login
 8:     -o-border-radius:50px;
Copy after login
 9:     border-radius:50px;
Copy after login
 10: }
Copy after login

 
Copy after login
Copy after login
HTML代码:
Copy after login
 
Copy after login
Copy after login

<p> 1: <div class="test"></div></p>
Copy after login

The effect is as follows:

To make the effect more obvious, now change the value of border-radius to 100px, which is half the width of div.test:

As you can see, it has now become a complete circle! ! ! ! If we pass through the center of the circle and draw a line in the horizontal and vertical directions, we can see that the arc of each corner is actually 1/4 arc of the circle drawn with this value as the radius.

Another example: when border-radius has multiple values ​​

Set border-radius: 100px 50px; (The code is similar to the above, just modified border-radius, so it is not repeated).

After testing, the effect is as follows on my Google, Firefox, IE9 and 10

If we are like the picture above. Set the upper left corner as "left", the upper right corner as "right", and so on. You will find that the rules of border-radius for two values ​​​​are like the rules of margin and padding: the first value represents upper and lower, and the second value represents upper and lower. The values ​​represent left and right.

Similarly set border-radius: 100px 50px 0px;

The effect is as follows:

Set border-radius: 100px 50px 25px 0px;

After testing, the effect is as follows

,

As mentioned before, the setting of border-radius value is like padding and miargin, which is very Simple.

Okay, now let’s summarize the usage:

When there is only one value, the four corners are rounded with the same radian. When there are only two values, the first value represents the upper left corner and the lower right corner, and the second value represents the upper right corner and the lower left corner. When there are three values, the first value represents the upper left corner, and the second value is the middle one. The value is the upper right corner and the lower left corner. The third value means that when there are four values ​​in the lower right corner, it is expressed in the order of upper left, upper right, lower right and lower left:

The full text ends here, please correct me if there are any mistakes!!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

See all articles