Vertically centering content of :before/:after pseudo-elements

前端 未结 6 1185
闹比i
闹比i 2020-11-29 17:51

I\'m trying to achieve something similar to this picture:

\"enter

I have an im

6条回答
  •  清酒与你
    2020-11-29 18:55

    Using flex in the pseudo element's css it is rather easy:

    .parent::after {
      content: "Pseudo child text";
      position: absolute;
      top: 0;
      right: 0;
      width: 30%;
      height: 100%;
      border: 1px solid red;
      display:flex;
      flex-direction:row;
      align-items: center;
      justify-content: center;
    }
    

    see https://jsfiddle.net/w408o7cq/

提交回复
热议问题