Horizontal Line in Background using Css3

前端 未结 8 1349
走了就别回头了
走了就别回头了 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:51

    Artur's solution creates a line however if you increase the px value it becomes clear that the line is still a gradient. This can be fixed by using a start and stop for the middle colour as such:

    p {
        background: linear-gradient(to bottom, white calc(50% - 1px), black calc(50% - 1px) calc(50% + 1px), white calc(50% + 1px));
    }
    

    The line will be double the thickness of the px value given (due to +px -px) so the above gives a horizontal 2px line across the center of the element.

提交回复
热议问题