【发布时间】:2016-08-13 15:50:07
【问题描述】:
如何在鼠标悬停时更改按钮的背景图片?也许让图像从左到右淡化?这“可行”吗?
【问题讨论】:
标签: javascript html css button
如何在鼠标悬停时更改按钮的背景图片?也许让图像从左到右淡化?这“可行”吗?
【问题讨论】:
标签: javascript html css button
关于你的初始按钮样式 你有 {background:url('image1.jpeg');宽度:100%;}。然后创建另一种名为 #button:hover {background:url('image2.jpeg);} 的样式 你的“也许”效果可以通过添加过渡到你的风格来实现#button
【讨论】:
尝试使用线性渐变(也许您可以使用图像!(或不))
#btn{
width:20%;
border: solid 1px rgba(171, 156, 156, 0.56);
border-radius:15px;
background: linear-gradient(to right, #2ede13 50%,#7ed755 50%);
background-size: 200% 100%;
background-position: right bottom;
transition-property: all;
transition: 1s;
}
#btn:hover {
background-position: left bottom;
color: black;
}
<button id="btn">Search</button>
【讨论】:
【讨论】:
示例代码快照:
<button id="buttonID">Search</button>
<style>
#buttonID:hover
{
background-color: black;
color: white;
}
enter code here
</style>
只需给出一个 ID 或类,并在样式表中 #elementID:hover 按钮的名称。
【讨论】: