將 CSS3 轉場與漸層背景結合使用
P粉217629009
P粉217629009 2023-08-23 21:25:42
0
2
418
<p>我試圖在滑鼠懸停時使用 css 在縮圖上轉換,以便在懸停時背景漸變淡入。轉換不起作用,但如果我只是將其更改為 <code>rgba()<!--代碼-->值,它工作正常。不支援漸層嗎?我也嘗試過使用圖像,它也不會轉換圖像。 </code></p><code> <p>我知道這是可能的,因為在另一篇文章中有人做到了,但我不知道到底是怎麼做到的。任何幫助> 這是一些可以使用的 CSS:</p> <pre class="brush:css;toolbar:false;">#container div a { -webkit-transition: background 0.2s linear; -moz-transition: background 0.2s linear; -o-transition: background 0.2s linear; transition: background 0.2s linear; position: absolute; width: 200px; height: 150px; border: 1px #000 solid; margin: 30px; z-index: 2 } #container div a:hover { background: -webkit-gradient(radial, 100 75, 100, 100 75, 0, from(rgba(0, 0, 0, .7)), to(rgba(0, 0, 0, .4))) } </pre> <p><br /></p></code>
P粉217629009
P粉217629009

全部回覆(2)
P粉226642568

一種解決方法是轉換背景位置以產生漸變變化的效果: http://sapphion.com/2011/10/css3-漸變轉場與背景位置/

#DemoGradient{  
    background: -webkit-linear-gradient(#C7D3DC,#5B798E);  
    background: -moz-linear-gradient(#C7D3DC,#5B798E);  
    background: -o-linear-gradient(#C7D3DC,#5B798E);  
    background: linear-gradient(#C7D3DC,#5B798E);  
  
    -webkit-transition: background 1s ease-out;  
    -moz-transition: background 1s ease-out;  
    -o-transition: background 1s ease-out;  
    transition: background 1s ease-out;  
  
    background-size:1px 200px;  
    border-radius: 10px;  
    border: 1px solid #839DB0;  
    cursor:pointer;  
    width: 150px;  
    height: 100px;  
}  
#DemoGradient:Hover{  
    background-position:100px;  
}  
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!