Development/HTML · CSS
[CSS] attr() 사용하기
레오나르도 다빈츠
2022. 6. 18. 23:53
속성을 사용하여 동적으로 콘텐츠를 넣어보자!
📄 HTML
<span data-desc="링크" class="info__icon link"></span>
<span data-desc="설정" class="info__icon setting"></span>
📄 CSS
&[data-desc]:hover {
&::before {
content: '';
position: absolute;
top: 5px;
right: 6px;
width: 0;
height: 25px;
border-right: 10px solid transparent;
border-bottom: 20px solid $white;
border-left: 10px solid transparent;
}
&::after {
content: attr(data-desc);
position: absolute;
top: 40px;
right: -13px;
width: 57px;
height: 35px;
border-radius: 5px;
font-weight: bold;
color: $kpi-black100;
text-align: center;
line-height: 35px;
background-color: $white;
}
}
}