html - 如何在悬停时向右移动箭头?
问题描述
如何使箭头的填充在悬停时向右移动箭头?即箭头从文本中向右移动,当hover消失时,它又回到了原来的位置。
#next {
cursor: pointer;
position: absolute;
float: right;
top: 50%;
width: auto;
color: #383736;
font-weight: bold;
font-size: 20px;
user-select: none;
right: 75px;
transition: 0.2s ease-in;
-o-transition: 0.2s ease-in;
-ms-transition: 0.2s ease-in;
-moz-transition: 0.2s ease-in;
-webkit-transition: 0.2s ease-in;
}
#next:before{
content:"Next";
position:absolute;
color:#383736;
right: 50%;
opacity: 0;
-webkit-transition: all 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550);
padding-right: 5px;
}
#next:hover:before{
right:100%;
transition: 0.6s ease-in;
-o-transition: 0.6s ease-in;
-ms-transition: 0.6s ease-in;
-moz-transition: 0.6s ease-in;
-webkit-transition: 0.6s ease-in;
opacity:1;
}
<a id="next"><span class="arrow">⟶</span></a>
解决方案
您可以在箭头元素(跨度)上使用翻译:
#next {
cursor: pointer;
position: absolute;
float: right;
top: 50%;
width: auto;
color: #383736;
font-weight: bold;
font-size: 20px;
user-select: none;
right: 75px;
transition: 0.2s ease-in;
}
#next:before {
content:"Next";
position:absolute;
color:#383736;
right: 50%;
opacity: 0;
transition: 0.6s ease-in;
padding-right: 5px;
}
#next:hover:before {
opacity: 1;
}
#next span {
display: inline-block;
transition: 0.6s ease-in;
}
#next:hover span {
transform: translateX(50%);
}
<a id="next"><span class="arrow">⟶</span></a>
推荐阅读
- mariadb - Mariadb布尔全文搜索否定逻辑?
- python-3.x - 在 python 中聚合大型数据集的最快、最有效的方法
- javascript - JavaScript 在对象中设置值
- node.js - Node.js 查看控制台的日志位置
- objective-c - CocoaPods 与 CommandLineTool 和 Dylib 目标的集成
- intellij-idea - 仅在 IntelliJ IDEA 中的失败测试中查找/替换
- ffmpeg - 来自两个摄像头的 ffmpeg 流视频具有相同的设备名称
- hadoop - 无法设置namenode进程xxxxx的优先级
- c++ - 指针未更新它在 void 函数中指向的值
- angular - Angular 6将服务注入类而不使用构造函数