Add a line in front of an element using a pseudo-class selector

Without further ado, let’s take a look at the renderings first

 

I used the h2 tag for the article, so I won’t go into the code without saying much.

h2{
  font-weight: bold;
  position: relative;
  padding-left: 16px;
  &::before{
    content:""; 
    width: 5px; 
    height:20px; 
    border-radius: 12px;
    position: absolute; 
    top: -2px; 
    left: 0; 
    background: #1d52ad;
	}
}

 

Guess you like

Origin blog.csdn.net/cwb_2120/article/details/131069122