0

I have a div and I want to have the background-color of the div scaling after an hover so I did the following:

li { 
  background-size:  0 0;
  transition: background-size 2s ease-in;
  -moz-transition: background-size 2s ease-in;
  -web-kit-transition: background-size 2s ease-in
}
li:hover {
  background-size:  100% 100%;
  background-color: rgba(0, 0, 0, 0.1);
}

I want to achieve a similar effect to the toolbars buttons hover on this website: http://www.materialup.com/posts/material-admin

Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87
Brandon Jose
  • 11
  • 1
  • 4

3 Answers3

1

you need to add a :before element through css to get the desired result.

demo

li {
  width: 40px;
  height: 40px;
  float: left;
  margin-right: 5px;
  background: white;
}

li:before {
  content: " ";
  transition: all 255ms ease-in;
  -moz-transition: all 255ms ease-in;
  -webkit-transition: all 255ms ease-in;
  transform: scale3d(0, 0, 0);
  -webkit-transform: scale3d(0, 0, 0);
  width: 40px;
  height: 40px;
  float: left;
  background-color: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

li:hover:before {
  transform: scale3d(1, 1, 1);
  opacity: 1;
}
Richa
  • 4,240
  • 5
  • 33
  • 50
0

I'm not exactly sure which toolbar button you mean, but if I understand your question correctly you want the background color wrapped around the listitem.

Adding display: inline-table; would normally get the job done.

Here's the fiddle with your example code: https://jsfiddle.net/5v5upekt/5/

Source

Community
  • 1
  • 1
0

Sample HTML

<div class="container">
  <h3>Inline List</h3>
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">Menu 1</a></li>
    <li><a href="#">Menu 2</a></li>
    <li><a href="#">Menu 3</a></li>
  </ul>
</div>

And CSS would be

.container{
      margin:auto;
      background-color:white;
      width:80%;
}


li:hover{
   -webkit-transform:scale(1.1);
   transform:scale(1.1);
   opacity: 0.8;
   background: rgba(0, 0, 0, 0.1) none repeat scroll 0% 0%;
   cursor:pointer;
   }

li{
    -webkit-transition: all 0.7s ease;
    transition: all 0.7s ease;
    cursor:pointer;
} 

You can find some hover and animation effects here

Here is the Demo

Please let me know is this what exactly you required.

Ramkee
  • 900
  • 1
  • 10
  • 27
  • I want to scale only the background color not the text who is with it because i know how to scale the whole thing but only the background is more difficult. – Brandon Jose Jun 02 '16 at 07:15