※ 부모태그에 position: relative; 주기
.클래스이름::after{
content: '';
width: 60px;
height: 2px;
background: #e94040;
position: absolute;
left: 50%;
bottom: -15px;
transform: translateX(-50%);
}
.클래스이름::after{
content: "";
width: 80px;
height: 2px;
background-color: rebeccapurple;
position: absolute;
left: 0;
bottom: -25px;
}
그외의 방법 (부모태그에 relative 안줘도됨)
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>CSS</title>
<style>
h1.a:after {
content: "";
display: block;
width: 60px;
border-bottom: 1px solid #bcbcbc;
margin: 20px 0px;
}
h1.b {
text-align: center;
}
h1.b:after {
content: "";
display: block;
width: 60px;
border-bottom: 1px solid #bcbcbc;
margin: 20px auto;
}
</style>
</head>
<body>
<h1 class="a">Lorem Ipsum Dolor</h1>
<h1 class="b">Lorem Ipsum Dolor</h1>
</body>
</html>
'css' 카테고리의 다른 글
Link와 @import 차이점 (0) | 2021.08.23 |
---|---|
그리스시스템에 맞게 코딩하기 (0) | 2021.07.21 |
반응형 nav 만들기 (0) | 2021.07.21 |
메뉴바 스르륵 나타나기 (0) | 2021.06.21 |
flexbox 블로그글 (0) | 2021.06.21 |