【发布时间】:2019-07-22 16:56:56
【问题描述】:
我的目标是,当我将鼠标悬停在按钮上时,背景颜色会淡入,但是当我的鼠标移出按钮时,我希望背景颜色会淡出。 所以我通过在 CSS 中为 button 和 button:hover 插入 transition 属性来做到这一点,以便它淡入淡出。我的下拉菜单上也有相同的按钮,可以产生相同的效果。顺便说一句,我是在 Atom 上做的,在 Atom 的预览浏览器包中似乎没有问题。
我尝试改变位置,过渡效果,但都不起作用。有什么想法吗?
这是我打开/刷新网页时按钮发生的情况: https://i.stack.imgur.com/uYTvB.gif
HTML:
<button onclick="location.href='Contact.html';" type="button">Book an Appointment <i class="fa fa-angle-right"></i></button>
CSS:
button {
cursor: pointer;
background:none;
color: white;
border: 1px solid orange;
border-radius: 20px;
padding: 10px 24px;
font-size: 13px;
text-transform: uppercase;
position: absolute;
top: 52%;
left: 42%;
text-align: center;
font-family: "Gotham";
font-weight: bold;
letter-spacing: 1px;
transition: all 1s ease-out;
}
button:hover {
transition: all .5s ease-in;
background: rgba(204, 204, 204, 0.5);
}
当我的鼠标悬停在第一次打开或刷新网页时,我希望按钮的背景颜色会淡入淡出。
【问题讨论】:
-
请不要仅仅因为解决了问题就删除内容...这个问题不太有用,不仅因为您的编辑,还因为您删除了 cmets。
标签: html css google-chrome atom-editor