0
A
回答
1
通過在:hover
上創建線性漸變透明白色透明和移動背景向前/向後實現的當前效果。
這裏的解決方案將圖像放置在此動畫下。但請記住,無盡的動畫可能非常分散注意力和惱人的爲你的用戶
.wrapper {
position: relative;
width: 350px;
height: 150px;
/*border: 2px solid #444;*/
border-radius: 10px;
overflow: hidden;
}
img {
position: relative;
z-index: 0;
width: 100%;
}
.gradient {
transition: background-position .5s;
background-size: 200% auto;
box-shadow: 0 0 20px #eee;
font: 0;
position: absolute;
z-index: 1;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.gradient {
background-image: linear-gradient(to top, transparent 0%, white 51%, transparent 100%);
background-position: center bottom;
}
.gradient:hover {
background-position: center top;
}
.gradient.animated {
animation: gradient 2s infinite;
}
@keyframes gradient {
0% {
background-position: center bottom;
}
50% {
background-position: center top;
}
100% {
background-position: center bottom;
}
}
<div class='wrapper'>
<div href='#' class='gradient'></div>
<img src='http://lorempixel.com/350/150/sports/' />
</div>
<div class='wrapper'>
<div href='#' class='gradient animated'></div>
<img src='http://lorempixel.com/350/150/sports/' />
</div>
,並更好地理解
你可以找到更多的文章下面
simplier例子
.gradiented {
transition: background-position .5s;
background-size: 200% auto;
box-shadow: 0 0 20px #eee;
border-radius: 10px;
width: 200px;
height: 200px;
}
.gradiented {
background-image: linear-gradient(to top, #283048 0%, #859398 51%, #283048 100%);
background-position: center bottom;
}
.gradiented:hover {
background-position: center top;
}
<div href='#' class='gradiented'></div>
+0
u能告訴我重複我怎樣才能讓動漫嬉戲自動(無鼠標移到圖片)? –
+1
@AliH編輯,看第一段 – godblessstrawberry
+0
@AliH yw,請記住無盡的動畫可能會讓你的用戶非常分心和煩人 – godblessstrawberry
相關問題
- 1. 使用線性梯度(純CSS)實現動畫蹺蹺板效果
- 2. 覆蓋線性梯度CSS屬性
- 3. CSS - 錯誤的線性梯度
- 4. 使用CSS動畫線性漸變
- 5. SVG - > WPF線性梯度
- 6. 重複線性梯度頁
- 7. 線性梯度工件
- 8. HTML帆布梯度動畫
- 9. css:什麼是鉻的-moz線性梯度的等值線
- 10. css梯度給滾動條
- 11. 與CSS梯度
- 12. CSS - 無限的動畫(移動到右裝載梯度)閃爍
- 13. IE8兼容性和線性梯度
- 14. 從梯形到右梯形的動畫變換充滿梯度
- 15. 不太敏感/ CSS線梯度背景
- 16. 提取梯度畫筆屬性
- 17. 梯度HTML5畫布
- 18. 的jQuery/CSS創建線性梯度僅具有一個顏色
- 19. 內聯CSS到角2 - 線性梯度到背景圖像
- 20. CSS梯度劣質
- 21. CSS梯度在IE9
- 22. CSS徑向梯度?
- 23. jQuery的CSS梯度
- 24. 新增CSS梯度
- 25. CSS瘋狂梯度
- 26. 使用CSS梯度來完成淡出
- 27. 式線性梯度不受Trigger.io
- 28. CSS3線性梯度純色大小
- 29. 改變梯度hr的線性值
- 30. 牛頓梯度下降線性迴歸
@Paulie_D它沒有提到的問題 – godblessstrawberry