KOKOC KOKOC - 4 months ago 7
CSS Question

CSS: changing image in div when hovering

The goal: to build two blocks which should change their background color, text color and icon when hovering.

The trouble: I have no problem with background and text, but I found some difficulties with icons. How can I edit my HTML or CSS to reach the goal?

Here are my code: https://jsfiddle.net/teyrq0ze/
and images that should be used when hovering:

http://i.imgur.com/8MqehqH.png
,
http://i.imgur.com/pNgIqxQ.png
.

Answer

Add filter to image on hovering over the divs.

body {
  margin: 0;
  padding: 0;
  width: 100%;
  color: #333;
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  background: #333;
}

#footerblurb {
  color: #fff;
}

#footerblurb-inner {
  margin: 0 auto;
  width: 650px;
}

#footerblurb .column1,
.column2 {
  float: left;
  display: table;
  width: 290px;
  padding: 15px;
  cursor: pointer;
  border: 1px dashed #fff;
  transition: all .1s ease-in-out;
  -webkit-transition: all .1s ease-in-out;
  -moz-transition: all .1s ease-in-out;
  -o-transition: all .1s ease-in-out;
}

#footerblurb .column1 {
  margin-right: 6px;
}

#footerblurb .column1:hover,
.column2:hover {
  color: #333;
  background: #fff;
}

#footerblurb .column1 img {
  float: left;
  vertical-align: middle;
  display: table-cell;
}

#footerblurb .column2 img {
  float: right;
  vertical-align: middle;
  display: table-cell;
}

#footerblurb .column1 span {
  text-align: center;
  vertical-align: middle;
  display: table-cell;
}

#footerblurb .column2 span {
  text-align: center;
  vertical-align: middle;
  display: table-cell;
}
#footerblurb .column1:hover img,
#footerblurb .column2:hover img{
	-webkit-filter: invert(100%); 
	filter: invert(100%);
}
<div id="footerblurb">
  <div id="footerblurb-inner">

    <div class="column1" onclick="location.href=''">
      <span><img class="previous" src="http://i.imgur.com/0tnecTN.png"></span>
      <span>text text text</span>
    </div>
    <div class="column2" onclick="location.href=''">
      <span>text text text</span>
      <span><img class="next" src="http://i.imgur.com/e86z3mD.png"></span>
    </div>

    <div class="clr"></div>
  </div>
</div>

updated Demo here

you can use different filtering to give different colors.

For more information read this