Rounded corners
The first CSS3 effect that we'll look at is rounded corners, since that was such a sought-after feature before CSS3. In the past, if you wanted rounded corners, there were only a few non-optimal solutions available. You could load four images, one for each corner, and add some extra markup to get them to line up (and try to make it work in all browsers). Or implement some kind of hack using multiple div
tags to "draw" a rounded border. Or one of a half a dozen other ways. In the end none of them were great solutions. So why did we go to such lengths to make rounded corners work before CSS3? Because people are attracted to them and they just seem to make your design look more natural.
Rounded corners are ridiculously easy to add to elements using CSS3's new border-radius
property. If you want each corner to have the same border radius, just give it one value, like this:
border-radius: 0.5em;
If you want to set each corner of the border to a different radius, you can do that too. The values are in the standard order for CSS properties, clockwise from the top-left: top-left, top-right, bottom-right, and bottom-left.
border-radius: 1px 4px 8px 12px;
You may set one, two, three, or all four values. One and four are self-explanatory.
- If two values are set, the first applies to top-left and bottom-right and the second applies to top-right and bottom-left. So it's opposite corners.
- If three values are set, the second value applies to top-right and bottom-left. The first applies to top-left and the third to bottom-right.
You can also define each corner's radius separately, as shown here:
border-top-left-radius: 1px; border-top-right-radius: 4px; border-bottom-right-radius: 8px; border-bottom-left-radius: 12px;
Note
Want to create a circle or ellipse? Set the border-radius
value to 50%
.

- Vue.js 3.x快速入門
- 軟件安全技術(shù)
- ASP.NET MVC4框架揭秘
- Rust編程:入門、實(shí)戰(zhàn)與進(jìn)階
- Linux核心技術(shù)從小白到大牛
- Java高手真經(jīng)(高級編程卷):Java Web高級開發(fā)技術(shù)
- 從程序員到架構(gòu)師:大數(shù)據(jù)量、緩存、高并發(fā)、微服務(wù)、多團(tuán)隊(duì)協(xié)同等核心場景實(shí)戰(zhàn)
- Architecting the Industrial Internet
- Android Native Development Kit Cookbook
- Python機(jī)器學(xué)習(xí)基礎(chǔ)教程
- Java面向?qū)ο蟪绦蛟O(shè)計
- SQL Server實(shí)用教程(SQL Server 2008版)
- Visual Basic程序設(shè)計全程指南
- Python Web自動化測試設(shè)計與實(shí)現(xiàn)
- 少兒編程輕松學(xué)(全2冊)