简体   繁体   中英

CSS hover transition / transform background color scale

I want an element's background color to change and for the element to grow slightly on hover.

The problem I have is that the background color is being applied on hover but it doesn't cover all of the enlarged div (as transformed using scale on hover).

Please see the attached image and code.

The lighter background should be flush to the dotted border on the left.

Any ideas?

#recent-posts li {
transition: all .1s;
-webkit-transition: all .1s;
-moz-transition: all .1s;
transform-origin:center bottom;
-webkit-transform-origin:center bottom;
-moz-transform-origin:center bottom;
}

#recent-posts li:hover {
transform:scale(1.1);
-moz-transform:scale(1.1);
-webkit-transform:scale(1.1);
background-color: rgba(0, 0, 0, 0.00);
}  

截图

Your background color has an alpha value of 0.

This makes it completely transparent so there is nothing to show of the background..

It looks like you want the hover color to be the same as the background of the container. In this case you should set the same color of the container as the :hover color of the li .

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