1 Question: Double border CSS

question created at Sat, Jun 1, 2019 12:00 AM

I have been working on a project and I was able to create a double border css with box shadow... but the problem is I need a transparency on the first box..

I tried something:

* {
  box-sizing: border-box;
}

body {
  display: flex;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
}

.box {
  width: 5rem;
  height: 3rem;
  background-color: #789;
  border: 3px solid black;
  box-shadow: 8px -8px 0 -3px #ccc, 8px -8px 0 0 #000;
}
<div class="box"></div>

I need http://prntscr.com/nw6fed - the background of the first box should be transparent...Any help

0
  1. 2019-06-01 11:58:58Z
1 Answers 1

You can get your second border with a pseudo element. I used :after in this example.

.box {
  width: 200px;
  height: 200px;
  border: 3px solid cyan;
  position: relative;
  padding: 40px;
  box-sizing: border-box;
}

.box::after {
  content: '';
  height: 100%;
  width: 100%;
  position: absolute;
  display: block;
  top: 20px;
  left: 20px;
  border: 3px solid magenta;
}
<div class="box">
  <h1>Text</h1>
</div>
4
2019-06-01 04:39:58Z
  1. Thank you @connexo. This was exactly I needed..
    2019-06-01 04:57:54Z
source placed here