자바스크립트로 tooltip
기능을 구현하다가 ::after
를 어떻게 적용해야 되는지 알아봤다.
일반적으로 가상요소를 적용할 때, ::after
처럼 세미콜론을 두개 사용해서 적용했는데, styled component
에서는 적용이 되지 않았다.
styled component
에서는 :
하나만 사용하면 된다.
예를 들어,
...
export const StyleTest = styled.span`
visibility: hidden;
width: 120px;
background-color: #101010d4;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 130%;
left: 50%;
margin-left: -60px;
&:after {
content: " ";
position: absolute;
border-width: 5px;
border-style: solid;
border-color: #101010d4 transparent transparent transparent;
top: 100%;
left: 50%;
margin-left: -5px;
}
`;
위와 같이 사용하면 가상요소를 적용할 수 있다.