css
짧은 밑줄 만들기
by 리양
2021. 7. 27.
※ 부모태그에 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>
https://www.codingfactory.net/10778