Offset border effect in pure css

前端 未结 2 780
醉梦人生
醉梦人生 2020-12-22 02:49

I am trying to create an offset border effect. Can this be done with pure css.

These are buttons so will be different sizes and colours.

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 03:29

    I use pseudo-element :after to create offset border effect.

    body {
      background: black;
      padding: 30px;
    }
    div {
      background: white;
      height: 75px;
      width: 175px;
      position: relative;
    }
    div:after {
      content: '';
      background: transparent;
      border: 1px solid white;
      top: 7px;
      right: 7px;
      bottom: -7px;
      left: -7px;
      position: absolute;
      z-index: -1;
    }

提交回复
热议问题