Danila
Danila

Reputation: 125

CSS: A non-standard shaped block with a border and rounded corners

I need to create a block like this:

enter image description here

I did it using an additional child block and four pseudo-elements. But there are probably better options. Please suggest something more elegant.

The problem is that there will be text and visual content inside. Therefore, simply drawing such a shape using svg is not an option. Maybe use clip-path somehow or something like that?

.wrapper {
  width: 320px;
  height: 370px;
  border: 2px solid red;
  border-radius: 10px;
  position: relative;
}
.wrapper:before,
.wrapper:after {
  content: '';
  display: block;
  width: 15px;
  height: 15px;
  background-color: #fff;
  position: absolute;
  z-index: 2;
}
.wrapper:before {
  left: -5px;
  top: 160px;
}
.wrapper:after {
  left: 95px;
  bottom: -5px;
}
.border-block {
  background-color: #fff;
  position: absolute;
  width: 100px;
  height: 200px;
  border-top: 2px solid red;
  border-right: 2px solid red;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  border-top-right-radius: 10px;
  left: -2px;
  bottom: -2px;
}
.border-block:before,
.border-block:after {
  content: '';
  display: block;
  width: 15px;
  height: 15px;
  border-left: 2px solid red;
  border-bottom: 2px solid red;
  border-bottom-left-radius: 10px;
  position: absolute;
  z-index: 3;
}
.border-block:before {
  top: -17px;
  left: -2px;
}
.border-block:after {
  bottom: -2px;
  left: 100px;
}
<div class="wrapper">
  <div class="border-block"></div>
</div>

Upvotes: 0

Views: 77

Answers (0)

Related Questions