CSS Change color of “:after” element on hover

前端 未结 3 1549
耶瑟儿~
耶瑟儿~ 2021-01-01 16:37

Lets say i have a list of elements :

  1. First
  2. Second
  3. Third
相关标签:
3条回答
  • 2021-01-01 16:58

    this works perfectly

    .topButton:hover:after{
        background-color: #000;
    }
    
    0 讨论(0)
  • 2021-01-01 17:01

    Her you go mate, did a bit of "fiddling" and got it working with CSS using

    .third:hover .sub{
          display:inline;   
    }
    

    :

    http://jsfiddle.net/79Lvn/3/

    0 讨论(0)
  • 2021-01-01 17:18

    As per ExtPro's comment, you can't

    But you can do like...

    HTML :

    <ol>
        <li>First<span> + More info</span></li>
        <li>Second<span> + More info</span></li>
        <li>Third<span> + More info</span></li>
    </ol>
    

    CSS :

    li > span {
        display:none;
    }
    
    li:hover > span {
        display:inline;
    }
    
    li > span:hover {
        color:red;
    }
    

    Use :active as onClick ?

    li > span:active {
        color:blue;
    }
    

    Demo : http://jsfiddle.net/79Lvn/2/


    or JS/jQuery way ? just...

    $('ol > li').append('<span> + More info</span>');
    

    Demo : http://jsfiddle.net/79Lvn/4/

    0 讨论(0)
提交回复
热议问题