使用 CSS3 過渡增強漸變背景
P粉955063662
P粉955063662 2023-10-12 18:05:11

我試圖在滑鼠懸停時使用 css 在縮圖上進行轉換,以便在懸停時背景漸變淡入。轉換不起作用,但如果我只是將其更改為 rgba() 值,它可以工作美好的。不支援漸層嗎?我也嘗試過使用圖像,它也不會轉換圖像。

我知道這是可能的,因為在另一篇文章中有人做到了,但我不知道到底是怎麼做到的。任何幫助> 這是一些可以使用的 CSS:

#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)))
}


#
P粉955063662
P粉955063662

全部回覆(2)
P粉107772015

一種解決方法是轉換背景位置以產生漸變變化的效果: 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學習者快速成長!