Double box/border? Is this possible in CSS?

前端 未结 4 1297
时光取名叫无心
时光取名叫无心 2021-01-17 17:20

I\'m trying to recreate this image in CSS.

This is what I got from experimenting, so far. I used box-shadow to act as the second box. I\'m not sure if there\'s a bet

4条回答
  •  醉梦人生
    2021-01-17 18:15

    You can achieve this via absolutely position pseudo element. Also avoid property duplication via CSS inheritance.

    .border {
      text-align: center;
      border: solid 3px black;
      border-radius: 5px;
      text-decoration: none;
      font-weight: 600;
      color: black;
      letter-spacing: 2px;
      padding: 20px 15px;
      margin: 15px 15px;
      background: white;
      
      position: relative; /* new */
    }
    
    /* new */
    .border:after {
      content: "";
      position: absolute;
      display: block;
      background: inherit;
      border-radius: inherit;
      border: inherit;
      left: 2px;
      top: 2px;
      width: 100%;
      height: 100%;
      z-index: -1;
    }
    3. Scouting for a location

提交回复
热议问题