简体   繁体   中英

Background color change on hover

I have done box around text. Now I want to be hover and change the color of the box
background. I am not able to change that when mouse hover. I have also attached the
image with this so you can have idea about. I have done box around text. Now I want to be hover and change the color of the box background. I am not able to change that when mouse hover. I have also attached the image with this so you can have idea about.please check the image and found the social media box , when I hover the mouse
the hover color is not changing.

 <style>
 div.ex
 {
     width:20px;
     height:20px; 
     padding:5px;
     border:1px solid #D8D8D8;
     margin:0px;
     background-color:#3b5998;
 }
 </style>


<div class="ex"><span class="iconfacebook2" aria-hidden="true" data-icon="&#xe169;">     
</span></div> 

查看图片以了解更多想法

*edited to make the image appear

You can use the :hover selector:

http://www.w3schools.com/cssref/sel_hover.asp

But if you are using images, you can apply CSS Image Sprites:

http://www.w3schools.com/css/css_image_sprites.asp

By the way, if you are developing a website, maybe CSS Image Sprites are a good choice to boost the performance of the website (because it uses only 1 native image for multiple image interactions).

;)

<style>
div.ex
{
width:20px;
height:20px; 
padding:5px;
border:1px solid #D8D8D8;
margin:0px;
background-color:#3b5998;
}
div.ex:hover {
background-color:#000;
}
 </style>

Create a hover element by taking the same css class div.ex and adding :hover

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM