Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
Unable to have a div with sharp corner instead getting it as rounded corner

I am trying to have a sharp cut div on the top right but instead using the border-top-right radius

I am getting a rounded corner on the top right.

How can we achieve this using only CSS

Currently how I am getting is rounded corners the rounded corners I am getting with the below code

Code sandbox link:- Sandbox

.container {
  width: 150px;
  height: 150px;
  position: relative;
  margin: 30px;
}

.box {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.7;
  background: #0057e3;
}

.overlay {
  z-index: 9;
  background: red;
  border-top-right-radius: 65px;
}
<div class="container">
  <div class="box"></div>
  <div class="box overlay"></div>
</div>

Instead How I need the div to be is sharp corners

How can I make the div as sharp corners only on the top right?

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

We can use before or after psuedo element to achieve this effect. enter image description here

HTML

<div>
  <h1>Hello</h1>
  <div class="container">
    <div class="box"></div>
  </div>
</div>

CSS

.box {
  width: 100%;
  height: 100%;
  position: relative;
  opacity: 0.7;
  background: #0057e3;
  border-radius: 10px;
  overflow: hidden;
}

.box::before {
  content: "";
  position: absolute;
  top: -45px;
  right: -45px;
  width: 200px;
  height: 30px;
  transform: rotate(45deg);
  background: red;
}
about 4 years ago · Santiago Gelvez Report

0

You can use clip-path instead of a rounded corner.

Here's the HTML/CSS of your code with just that alteration:

html,
body {
  font-family: sans-serif;
  h1 {
    color: tomato;
  }
}

.container {
  width: 150px;
  height: 150px;
  position: relative;
  margin: 30px;
}

.box {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.7;
  background: #0057e3;
}

.overlay {
  z-index: 9;
  background: red;
  /*border-top-right-radius: 65px;*/
  clip-path: polygon(0 0, 70% 0, 100% 30%, 100% 100%, 0 100%);
}
<div class="container">
  <div class="box"></div>
  <div class="box overlay"></div>
</div>

about 4 years ago · Santiago Gelvez Report

0

You can't have sharp corners in pure CSS using the border-radius

A workaround is to use -webkit-mask

.overlay {
  -webkit-mask: linear-gradient(to top right, #FFF 85%, #ffffff00 85%) top left;
  background: hotpink;
  position:absolute;
  width:100%;
  height:100%:
}

div {
  width:200px;
  height:200px;
  position: relative;
  background: cyan;
}
<div>
  <div class='overlay'>
  Corner using webkit-mask
  </div>
</div>

Check this for more details

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!