问题描述
I'm trying to create an CSS button hover effect. But I didn't manage to fill the element with a slanted shape.
How the hover effect was planned:
Screenshot 1: How it looks actually.
Screenshot 2: How I want the hover effect to look like with slanted side.
I believe that you are actually looking for the end state to fill the entire element with background color and not leave the gap. You could also do it with linear-gradient
background images and transition their background-size
and background-position
like in the below snippet.
One disadvantage of using linear-gradient
over pseudo-elements or transforms is that the browser support is lower but it doesn't need extra pseudo-elements and so can leave them spare for other use.
这篇关于悬停时用倾斜背景填充元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!