Dotted top and bottom border shorter than text

后端 未结 3 1814
野性不改
野性不改 2021-01-02 06:06

I want to achieve border top and bottom like below image how can I achieve with CSS tricks?

\"Image\"

Chall

3条回答
  •  萌比男神i
    2021-01-02 06:38

    You can use box-shadows also to achieve this, first create an after psuedo-element on top and a before pseudo-element on bottom then give the two of the box-shadows

    body{
    	background:#09858F;
    }
    
    div{
    	position:relative;
    	display:inline-block;
    	margin:100px;
    }
    h1{
    	text-align:center;
    	font-family: Calibri;
    	font-size:50px;
    	color:#fff;
    	margin:50px;
    }
    
    h1:after{
    	content:"";
    	position:absolute;
    	left:30%;
    	height:10px;
    	width:10px;
    	background:yellow;
    	top:20%;
    	border-radius:50%;
    	box-shadow:20px 0 0 0  yellow,40px 0 0 0  yellow,60px 0 0 0  yellow,80px 0 0 0  yellow,100px 0 0 0  yellow,120px 0 0 0  yellow,140px 0 0 0  yellow,160px 0 0 0  yellow;
    }
    h1:before{
    	content:"";
    	position:absolute;
    	left:30%;
    	height:10px;
    	width:10px;
    	background:yellow;
    	bottom:20%;
    	border-radius:50%;
    	box-shadow:20px 0 0 0  yellow,40px 0 0 0  yellow,60px 0 0 0  yellow,80px 0 0 0  yellow,100px 0 0 0  yellow,120px 0 0 0  yellow,140px 0 0 0  yellow,160px 0 0 0  yellow;
    }

    How it Works

提交回复
热议问题