2016-07-22 96 views
1

我正在学习有关CSS的渐变效果,后来我发现这个buuton,我搜索了很多发现互联网上的任何解决方案来创建相同的按钮效果。是否有可能在css中创建它? Button高级渐变效果按钮CSS3

+0

您可以使用背景图像作为替代。 –

+0

是的,我可以使用它。但我正在学习渐变效果,这就是为什么我问过。 –

回答

2

它实际上是可能的,但不是仅适用于CSS梯度。

您必须使用SVG的曲线,鼠标悬停在一个梯度产生这样的效果。

.button { 
 
    display: inline-block; 
 
    padding: 0.5em 1em; 
 
    border-radius: 5px; 
 
    border: 1px solid #FAB14C; 
 
    
 
    /* Two background image: a SVG curve hover a linear-gradient */ 
 
    background-image: 
 
    url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 100" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><path d="M0,80 C50,100 50,0 100,20 L100,100 L0,100" fill="%23FAB14C"></path></svg>'), 
 
    linear-gradient(to top, #FAB14C, white); 
 
    
 
    /* The backgrounds are stretch to the element size */ 
 
    background-size: 100% 100%; 
 
    background-repeat: no-repeat; 
 
    
 
    text-transform: uppercase; 
 
    font-family: sans-serif; 
 
    cursor: pointer; 
 
}
<button type="button" class="button"> 
 
    Edit this article 
 
</button>

+0

它刚刚完美。由于 –

+0

为了好玩,我还添加了一个悬停效果=> https://jsfiddle.net/tzi/z1dj5bzL/ – tzi