Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my border-radius curve outward?

Tags:

I am try to make a div have borders like the following drawing:

enter image description here

This is what I have tried:

div {      height: 100px;      width: 100px;      border-bottom-right-radius:100px 10px;      border:1px solid #000;  }
<div></div>

What is an effect way to accomplish this?

like image 580
user3741635 Avatar asked May 08 '15 01:05

user3741635


People also ask

Which property helps create rounded border?

The border-radius property can be used to create rounded corners. This property typically defines the shape of the corner of the outer border edge.

How do you reverse the radius of a border?

The trick to making the inverted border radius (at least using this method) is to create a pseudo element, and then cut a normal border radius out of that element. Let's set up the pseudo element, and let's at the same time already add the border radius to it to speed life up a little bit!

How do you add a border radius to the right side?

CSS Syntaxborder-top-right-radius: length|% [length|%]|initial|inherit; Note: If you set two values, the first one is for the top border, and the second one for the right border. If the second value is omitted, it is copied from the first. If either length is zero, the corner is square, not rounded.


1 Answers

Using :before and :after

Example

The top border is created with the :before:

  • Its height is the same as the border radius

  • It is positioned just outside with top and lines up with the left border thanks to left

  • Its width is calculated with calc to precisely line up the top of the curve

  • The curve can be refined with transform: skewX(-60deg)

The left border is created with the :after:

  • It is given a 100% height minus the height of the before and the thickness of the border with calc

Examples

Number 1 - a bit pointy

div {   border-bottom-right-radius: 100px 20px;   border: 1px solid #000;   border-top: none;   height: 500px;   width: 200px;   position: relative;   border-left: none; } div:before, div:after {   content: '';   display: block;   position: absolute;   left: -1px; } div:before {   height: 20px;   width: 100%;   width: calc(100% + 1px);   border-bottom-right-radius: 100px 20px;   border-bottom: 1px solid #000;   border-right: solid 1px #000;   top: -1px; } div:after {   height: calc(100% - 18px);   border-left: 1px solid #000;   top: 19px; }
<div></div>

Number 2 - smoothed out point with skew

div {   border-bottom-right-radius: 100px 20px;   border: 1px solid #000;   border-top: none;   height: 200px;   width: 200px;   position: relative;   border-left: none; } div:before, div:after {   content: '';   display: block;   position: absolute;   left: -1px; } div:before {   height: 20px;   width: 100%;   width: calc(100% - 36px);   border-bottom-right-radius: 100px 20px;   border-bottom: 1px solid #000;   border-right: solid 2px #000;   top: 0px;   left: 17px;   transform: skewX(-60deg); } div:after {   height: calc(100% - 19px);   border-left: 1px solid #000;   top: 20px; }
<div></div>
like image 173
misterManSam Avatar answered Sep 20 '22 08:09

misterManSam