07. Border Radius border-radius

Border Radius

Boxes that have straight corners are often unappealing to the eye. To make a more smooth, rounded corner, we can use the border-radius property.

We specify a unit length for the radius - the larger this is, the more circular your corners become.

With a border-radius of 5px.
With a border-radius of 10px.
With a border-radius of 10px 20px.
With a border-radius of 10px 15px 20px 25px.

Specifying a specific corner

If you'd like to specify specific a specific corner, use:border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius

The shorthand for these is from border-radius.

  1. One value specifies all corners.
  2. Two values specify the top-left/bottom-right, and top-right/bottom-left.
  3. Three values specify top-left, top-right/bottom-left, and bottom-right.

Creating an Ellipse

To create an ellipse, specify a width and height, then give two unequal values for the border-radius, separated by a forward slash (/).

#oval {
  width: 200px;
  height: 100px;
  border-radius: 100px / 50px;
  background: blue;
  margin: 10px auto;
}

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Build modern and responsive webpages

JavaScript & JQuery

Build modern and responsive webpages Try Front-end

This book was written for anyone who wants to use JavaScript to make their websites a little more interesting, engaging, interactive, or usable. In particular, it is aimed at people who do not have a degree in computer science (well, not yet anyway).

$ Check price
39.9939.99Amazon 4.5 logo(385+ reviews)

More Front-end resources

Ad