Combine :after with :hover

前端 未结 3 1705
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 16:54

I want to combine :after with :hover in CSS (or any other pseudo selector). I basically have a list and the item with the selected cl

相关标签:
3条回答
  • 2020-11-29 17:09
     #alertlist li:hover:after,#alertlist li.selected:after
    {
        position:absolute;
        top: 0;
        right:-10px;
        bottom:0;
    
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid #303030;
        content: "";
    }​
    

    jsFiddle Link

    0 讨论(0)
  • 2020-11-29 17:10

    in scss

    &::after{
    content: url(images/RelativeProjectsArr.png);
    margin-left:30px;
    }
    
    &:hover{
        background-color:$turkiz;
        color:#e5e7ef;
    
        &::after{
        content: url(images/RelativeProjectsArrHover.png);
        }
    }
    
    0 讨论(0)
  • 2020-11-29 17:11

    Just append :after to your #alertlist li:hover selector the same way you do with your #alertlist li.selected selector:

    #alertlist li.selected:after, #alertlist li:hover:after
    {
        position:absolute;
        top: 0;
        right:-10px;
        bottom:0;
    
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid #303030;
        content: "";
    }
    
    0 讨论(0)
提交回复
热议问题