html - 页面打开时如何修复按钮转换为带边框的自定义按钮?
问题描述
我的目标是,当我将鼠标悬停在按钮上时,背景颜色会淡入,但是当我的鼠标移出按钮时,我希望背景颜色会淡出。所以我通过在 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);
}
当我的鼠标悬停在第一次打开或刷新网页时没有任何动画时,我希望按钮的背景颜色会淡入淡出。
解决方案
在您的 CSS 中添加了一些更改
<button onclick="location.href='Contact.html';" type="button">Book an Appointment <i class="fa fa-angle-right"></i></button>
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;
text-align: center;
font-family: "Gotham";
font-weight: bold;
letter-spacing: 1px;
transition: all 1s;
}
button:hover {
transition: all .5s ease-in;
background: rgba(204, 204, 204, 0.5);
}
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;
text-align: center;
font-family: "Gotham";
font-weight: bold;
letter-spacing: 1px;
transition: all 1s;
}
button:hover {
transition: all .5s ease-in;
background: rgba(204, 204, 204, 0.5);
}
<button onclick="location.href='Contact.html';" type="button">Book an Appointment <i class="fa fa-angle-right"></i></button>
推荐阅读
- java - 如何使用 Jena 获取资源的 EXPLICIT listProperties(非推断属性)
- c - 测量执行函数所花费的时间
- python - 我在哪里可以找到 Azure 中的“storage_account_name”、“storage_account_key”、“storage_container_name”?
- r - R数据集中的TextInput过滤器闪亮
- node.js - 目前在 Node v 10 中使用 ES6 / Import 语句等最简单的方法是什么
- typescript - 如何将 typescript npm 模块导入语法转换为 ECMA2015 模块导入语法
- javascript - D3js 将 SVG 导出为图像
- intellij-idea - 在本地编辑远程文件并将它们提交到 intellijea IDEA
- python - 将熊猫数据框中的行相乘
- mysql - 如何选择总和达到1000的行?