Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to adjust the center of border-radius to the corner?

Please consider the following code:

.myClass {
  position: absolute;
  cursor: pointer;
  top: 50%;
  right: 50%;
  height: 100px;
  width: 300px;
  background-color: #729fcf;
  border-top-right-radius: 50px;
}
<span class="myClass"></span>

Here the center of the curve (of the border top right corner) is inside the span (which appears as a box).

I want the center of the curve to be at the corner ( the corner if there was no border-radius).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That is, I want the result to be like the picture below:

enter image description here

Is there any way I can do this?

A solution with pure CSS will be appreciated but if not possible, may be JavaScript also….

>Solution :

You can use CSS masks to achieve the desired result:

.myClass {
    position: absolute;
    cursor: pointer;
    top: 50%;
    right: 50%;
    height: 100px;
    width: 300px;
    background-color: #729fcf;
    mask-image: radial-gradient(circle at top right, transparent 0, transparent 20px, black 21px);
    mask-position: top right;
    mask-repeat: no-repeat;
    mask-size: 50% 50%;
    -webkit-mask-image: radial-gradient(circle at top right, transparent 0, transparent  20px, black 21px);
    -webkit-mask-position: top right;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: 50% 50%;
}
<span class="myClass"></span>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading