0

I'm currently trying to achieve this: enter image description here

But when border-radius: 15px 15px 0 0 I get this: enter image description here

Trondro Mulligan
  • 485
  • 3
  • 19

2 Answers2

2

Border-radius alone doesn't answer this but you can do it like this:

Overflow hidden on an outer box with circle corners: https://codepen.io/sergejmueller/pen/fJEml

border-radius: 50%;

You can also use radial gradients: http://lea.verou.me/2011/03/beveled-corners-negative-border-radius-with-css3-gradients/

background-image:
radial-gradient(circle at 0 0, rgba(204,0,0,0) 14px, #c00 15px),
radial-gradient(circle at 100% 0, rgba(204,0,0,0) 14px, #c00 15px),
radial-gradient(circle at 100% 100%, rgba(204,0,0,0) 14px, #c00     15px),
radial-gradient(circle at 0 100%, rgba(204,0,0,0) 14px, #c00 15px);

Also mask image for a modern solution:

-webkit-mask-image: radial-gradient(circle 10px at 0 0, transparent 0, transparent 20px, black 21px);
Jon Wood
  • 1,531
  • 14
  • 24
  • I think that using ::before would be better. This way you are creating unnecessary HTML markup. – Andre Aquiles Apr 03 '17 at 11:47
  • It's still the same idea though. ::before and ::after are just pseudo elements – Jon Wood Apr 03 '17 at 11:48
  • Yeah! Its the same idea indeed! +1 for that. But creating a habit of an optimized code is a good start to everyone. In a larger project, it may significantly improve his project just by using good habits such as this. – Andre Aquiles Apr 03 '17 at 11:53
1

You can do using this :beforecss selector:

.box{
  background:red;
  width:50px;
  height:100px;
  border-radius:3px;
  position:relative;
  margin-top:30px;
}
.box:before{
  content:"";
  width:50px;
  height:30px;
  border-radius:100%;
  background:#fff;
  position: absolute;
  top: -17px;
}
<div class="box">
</div>
Mukesh Ram
  • 6,248
  • 4
  • 19
  • 37