I need to make a shape like the picture below using CSS. There will be a number in the corner and content inside. Please tell me how to do it?
I was only able to do this:
.container {
position: relative;
width: 200px;
height: 200px;
background-color: #f2f2f2;
border-top-right-radius: 80px;
border-bottom-left-radius: 80px;
}
.background {
position: relative;
top: -20px;
left: -20px;
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
}
.number {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
color: #ffffff;
font-size: 24px;
}
<div class="container">
<div class="background">
<span class="number">1</span>
</div>
</div>
2
Answers
Try this out. Basically it’s just a square with one rounded corner. Then the two angled pieces are the
::before
and::after
elements rotated and manually placed. It’s not perfect but it’s close.Here is a fairly close version. There is definitely some "magic numbers" going on in here, but visually it’s pretty close.
Codepen version:
https://codepen.io/seanstopnik/pen/ZEmBJrL/e14888d3196306b79a82cfecbcb44eb4