div background color, to change onhover

后端 未结 10 1240
轮回少年
轮回少年 2020-11-27 04:54

I\'m trying to make a div\'s background color change on mouse over.

the div {background:white;}
the div a:hover{background:grey

相关标签:
10条回答
  • 2020-11-27 05:35

    Just make the property !important in your css file so that background color doesnot change on mouse over.This worked for me.

    Example:

    .fbColor {
        background-color: #3b5998 !important;
        color: white;
    }
    
    0 讨论(0)
  • 2020-11-27 05:38

    There is no need to put anchor. To change style of div on hover then Change background color of div on hover.

    <div class="div_hover"> Change div background color on hover</div>
    

    In .css page

    .div_hover { background-color: #FFFFFF; }
    
    .div_hover:hover { background-color: #000000; }
    
    0 讨论(0)
  • 2020-11-27 05:38

    Set

    display: block;
    

    on a and give some height

    0 讨论(0)
  • 2020-11-27 05:39

    You can just put the anchor around the div.

    <a class="big-link"><div>this is a div</div></a>
    

    and then

    a.big-link {
    background-color: 888;
    }
    a.big-link:hover {
     background-color: f88;
    }
    
    0 讨论(0)
提交回复
热议问题