文字の横に線(ライン)を引く方法1

線は画面いっぱい引かれます。

HTML
1
<p>タイトル</p>

文字に右側だけにライン

SCSS
1
2
3
4
5
6
7
8
9
10
p {
    display: flex;
    align-items: center;
    &::after {
        border-top: 1px solid;
        content: "";
        flex-grow: 1;
        margin-left: 1rem;
    }
}

文字の両脇にライン

SCSS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
p {
    display: flex;
    align-items: center;
    &::before, &::after {
        border-top: 1px solid;
        content: "";
        flex-grow: 1;
    }
    &::before {
        margin-right: 1rem;
    }
    &::after {
        margin-left: 1rem;
    }
}

こちらのページを参考にさせていただきました。