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

CSS3 study notes border-radius_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:33:55
Original
1249 people have browsed it

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!!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template