Creating a CSS double border line with a step in the middle

前端 未结 4 1846
日久生厌
日久生厌 2021-01-04 12:54

I\'m trying to achieve this(Pic below) with strictly CSS and HTML for this header to be displayed on mobile devices. I was able to get it done, although I believe my way of

4条回答
  •  清歌不尽
    2021-01-04 13:16

    Double skewed border

    Note Would recommend using SVG for this.

    CSS:

    • one element
    • two pseudo elements

    Used a lot of calc() with percentage values to get it to be fully responsive.
    Used a lot of border-style double since this seemed like the easiest way render the borders.
    The one element that is skewed is an absolute positioned element with a white background.
    So you will probably need to to have a solid color background.

    .extra-border {
      position: relative;
      border-bottom: 11px double black;
      border-top: 3px solid black;
      height: 150px;
      width: 100%;
      box-sizing: border-box;
    }
    .extra-border::before {
      content: "";
      position: absolute;
      display: inline-block;
      width: 50%;
      height: 15%;
      background-color: white;
      bottom: -11px;
      right: 0;
      border-top: 11px double black;
      border-bottom: 11px solid transparent;
    }
    .extra-border::after {
      content: "";
      position: absolute;
      display: inline-block;
      background-color: white;
      width: 20px;
      height: calc(20% + 19px);
      border-left: 13px double black;
      right: calc(50% - 11px);
      bottom: -20px;
      transform-origin: center center;
      transform: rotate(45deg);
    }

提交回复
热议问题