我目前正在研究一些新的東西,並且我已經介紹了SVG對象的世界。他們很好。無論如何,我有一個我已經構建的按鈕,並且在其上放置了一個過濾器。我正在使用的設計者希望在懸停時將過濾器(投影)從不透明度1變爲0,並且將光標移回1。SVG過濾器不會在使用轉換懸停時消失
我已經嘗試了過濾器上的正常過渡,我可以讓過濾器消失,但過渡並不平坦。
這裏是我的代碼:
HTML
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 216 216" style="enable-background:new 0 0 216 216;" xml:space="preserve">
<filter id="fade" height="150%" width='150%'>
<feMerge>
<feMergeNode/>
<!-- this contains the offset blurred image -->
<feMergeNode in="SourceGraphic" />
<!-- this contains the element that the filter is applied to -->
</feMerge>
</filter>
<filter id="dropshadow" height="150%" width='150%'>
<feGaussianBlur in="SourceAlpha" stdDeviation="25" />
<!-- stdDeviation is how much to blur -->
<feOffset dx="0" dy="15vh" result="offsetblur" />
<!-- how much to offset -->
<feComponentTransfer>
<feFuncA type="linear" slope="0.4" />
</feComponentTransfer>
<feMerge>
<feMergeNode/>
<!-- this contains the offset blurred image -->
<feMergeNode in="SourceGraphic" />
<!-- this contains the element that the filter is applied to -->
</feMerge>
</filter>
<a href='' id='playvideo_button'>
<g>
<path class="st0" d="M108,24c-46.4,0-84,37.6-84,84s37.6,84,84,84s84-37.6,84-84S154.4,24,108,24z" />
<polygon class="st1" points="92,140 92,76 140,108" />
</g>
</a>
</svg>
CSS
svg {
width: 30vw;
height: 30vh;
cursor: pointer;
}
svg .st0 {
fill: #4982CF;
transition: filter.6s ease-out;
filter: url(#dropshadow);
}
svg .st1 {
fill: #ffffff;
}
svg:hover .st0{
filter: url(#fade);
}
在這裏,也就是我的小提琴一個鏈接,我一直在玩弄,請讓我知道是否需要額外的資源!預先感謝您的幫助。
https://jsfiddle.net/sfza69ry/7/
EDITS
我已經創建了一個第二過濾器,這僅僅是一個透明的疊加,但也失敗了,做了同樣的不流暢的效果。
我在這裏非常茫然。
透明度不是一個過濾器,它反正拼寫錯誤。 –
@RobertLongson我編輯我的代碼,我沒有注意到,這是我的舊的東西,任何方式,這是我一直在努力着,其效果得到了陰影消失將工作,但它不會褪色順利。 –