2

enter image description here

This is a div that stretches the whole mobile screen; I'd want it to have a tilted curve(as shown in image) from top-right to top-left. I tried border-radius but that didn't work as expected. Is there a way to do this using CSS?

gopal prabhu
  • 213
  • 1
  • 3
  • 10

1 Answers1

1

Perhaps clip-path property might work for you.....

.container {
  background: #f6eee0;
  clip-path: polygon(0 10%, 100% -2%, 100% 100%, 0 100%);
  height: 80vh;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container"></div>
  </body>
</html>

Here is the updated snippet including the curve, if you need to increase/decrease the size of the curve just play around with the negative value in the clip-path property until you find the sweet spot and suits you the best...

Uzair Saiyed
  • 575
  • 1
  • 6
  • 16
  • Hey Uzair, This Helps a lot, Thanks. btw Is there a way to get the Curve too? (If you notice the provided image, its not a Straight line, has a small curve..) – gopal prabhu Jun 28 '21 at 18:54
  • Hey @gopalprabhu I thought there was a curve but due to the color of the image, it was kind of hard to see, and yes the curve is indeed possible, I am updating my code for the same....... – Uzair Saiyed Jun 29 '21 at 00:23