1

I’m trying to make a login form with an unusual shape, but I’m struggling with the border-radius on a <div> with a clip-path.

This is the CSS I used on a <div>:

background: red;
height: 80%;
-webkit-clip-path: polygon(100% 0, 0 0, 100% 100%);
clip-path: polygon(100% 0, 0 0, 100% 100%);
border-radius: 5em;

It currently looks like this:

Picture showcasing the problem.

As you can see, the border-radius in the upper-left and lower-right corners are cut off. Is there a workaround to make this clean?

Instead of the corners being cut off I'd like them to be as shown in the image below.

Picture showcasing the desired result.

4
  • @PeterB I'm sorry, I just added the CSS I use on a div. Commented Jul 31, 2018 at 15:30
  • @Xufox I added a picture showcasing the desired result, I hope it's clear to understand. Thanks for improving this post Commented Jul 31, 2018 at 15:39
  • 1
    Looks like you'll need to make the clip-path a lot more detailed (to have dozens or even hundreds of points very close to each other). Commented Jul 31, 2018 at 15:41
  • I'd be thinking of an SVG for this, Pretty sure it would be too involved for a CSS clip-path. Polygons don't have curves as such...just sides. Commented Jul 31, 2018 at 16:02

2 Answers 2

0

Try this:

.block {
  background: red;
  height: 300px;
  width: 200px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 0);
  border-radius: 10px;
}
 <div class="block"></div>

Sign up to request clarification or add additional context in comments.

Comments

0

This article is helpful: dev.to/afif/css-shapes-with-rounded-corners-56h

Your example:

.block {
  display:inline-block;
  width:460px;
  height: 500px;
  color:red;
  margin:20px;
  filter:url(#round);
  backgroudn: red;
}
.block::before {
   content:"";
   display:block;
   padding-top:100%;
   background: red;
 
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
<div class="block"></div>

<svg style="visibility: hidden; position: absolute;" width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
  <defs>
        <filter id="round">
            <feGaussianBlur in="SourceGraphic" stdDeviation="5" result="blur" />    
            <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 19 -9" result="goo" />
            <feComposite in="SourceGraphic" in2="goo" operator="atop"/>
        </filter>
    </defs>
</svg>

If you want to change the value of radial corners then change the attribute stdDeviation in SVG tag.

The solution has one problem is to display incorrect for IOS

I suggest you to use SVG for similar geometry

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.