Adding
using the :after selector

后端 未结 5 1230
甜味超标
甜味超标 2021-02-07 02:03

I\'m trying to \"automatically\" add a horizontal-rule after each article in my page. Is there a way of doing this using the :after selector? I\'m hoping to be able to style it

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 02:47

    CSS only solution

    article {
        position: relative;
    }
    
    article:after {
        content: '';
        position: absolute;
        width: 100%;
        height: 1px; // suit your need
        background: black; // suit your need
        top: 100%;
        left: 0;
    }
    

提交回复
热议问题