-1

I can't figure out, how I can achieve borders like this:

enter image description here

I was trying with after pseudoelement, like below but I learned from this topic: Why can't an element with a z-index value cover its child? that it's impossible.

I was thinking also about box shadow and outline but nothing seems to be a good solution. Any idea, please?

.wp-block-group.is-style-black-blue-border {
  position: relative;
  z-index: 1;
  border: 3px solid #000;
  border-radius: 8px;
  padding: 10px;
}

.wp-block-group.is-style-black-blue-border::after {
  content: "";
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  display: block;
  position: absolute;
  bottom: -8px;
  right: -8px;
  z-index: -1;
  border: 3px solid blue;
  border-radius: 8px;
}
<div class="wp-block-group is-style-black-blue-border">
  <div class="wp-block-group__inner-container">
    <p>some content</p>
  </div>
</div>
maja
  • 175
  • 5
  • 17

1 Answers1

1

As an alternative you can use box-shadow to create a similar effect. See below.

Edited to add: The effect can be done, see below

.wp-block-group.is-style-black-blue-border {
  position: relative;
  background-color:white;
  border: 3px solid #000;
  border-radius: 8px;
  padding: 10px;
  width: 200px;
  height: 100px;
  
}

.wp-block-group.is-style-black-blue-border::after {
  content: "";
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: -1;
  border: 3px solid blue;
  border-radius: 8px;
}
<div class="wp-block-group is-style-black-blue-border">
  <div class="wp-block-group__inner-container">
    <p>some content</p>
  </div>
</div>

.wp-block-group__inner-container {
  border: 2px solid black;
  border-radius: 1rem;
  box-shadow: 5px 5px 0px 2px #ffffff, 8px 8px 0px 4px #0000ff;
  width: 200px;
  height: 200px;
  padding: 1rem;
}
<div class="wp-block-group__inner-container">
    <p>some content</p>
</div>
Adam
  • 5,495
  • 2
  • 7
  • 24
  • It wasn't me who downvoted and thank you for your answer, but it isn't exactly what I need. Note corners. They don't look same as on project when using box-shadow. – maja Sep 16 '22 at 14:11
  • How about this? https://codepen.io/adamuk73/pen/zYjZrvK – Adam Sep 16 '22 at 14:32
  • @maja *but it isn't exactly what I need* --> don't accept answers if they don't solve your issue. You are sending a wrong signal to futures user and creating confusion. – Temani Afif Sep 16 '22 at 15:21
  • It was probably for the codepen. I've edited the main post so the given answer matches maja's requirements so it makes sense to other readers. – Adam Sep 16 '22 at 15:36