Horizontal Line in Background using Css3

前端 未结 8 1330
走了就别回头了
走了就别回头了 2021-02-07 08:05

How to implement this type of style to text using only css3, means a horizontal line in the middle of the tag... Can it be possible using pure css...

8条回答
  •  礼貌的吻别
    2021-02-07 08:41

    An alternative with flex and ::before and ::after. With this solution, you don't need to use a background for the content.

    With this HTML markup :

    4 weeks ago

    And this CSS :

    .datedAside {
      display: flex;
      flex-flow: nowrap;
      justify-content: space-between;
      align-items: center;
    }
    
    .datedAside span {
      padding: 1em;
    
    }
    
    .datedAside::before, 
    .datedAside::after {
      flex-grow: 1;
      flex-shrink: 1;
      flex-basis: auto;
      content: " ";
      height: 0px;
      border-bottom: 1px solid black;
    }
    

提交回复
热议问题