【发布时间】:2019-09-02 04:09:45
【问题描述】:
我想创建一个在悬停时显示箭头的按钮,但我希望该箭头从右侧进入并在按钮内浮动,而不管按钮的大小。
以下是我到目前为止所取得的成就。
.button {
background-color: rgb(37,37,37);
background-image: none;
border-radius: 4px;
border: none;
color: #BEC4C9;
cursor: pointer;
display: block;
fill: none;
font-family: Arial;
font-size: 14px;
font-weight: bold;
height: auto;
line-height: 18.2px;
margin: 5px 1.4px 20px 0;
overflow: hidden;
padding: 5.6px 22.9071px 5.6px 14px;
text-align: left;
vertical-align: baseline;
width: auto;
}
.button span {
cursor: pointer; position: relative; transition: 0.5s;
}
.button span:after {
content: '\►'; position: absolute; opacity: 0; top: 0; right: 0;
}
.button:hover span {
padding-right: 23px; color: #ffffff;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.buttonAfter {
background-color: rgb(37,37,37);
background-image: none;
border-radius: 4px;
border: none;
color: #ffffff;
cursor: pointer;
display: block;
fill: none;
font-family: Arial;
font-size: 14px;
font-weight: bold;
height: auto;
line-height: 18.2px;
margin: 5px 1.4px 20px 0;
overflow: hidden;
padding: 5.6px 5px 5.6px 14px;
text-align: left;
transition: all 0.5s;
vertical-align: baseline;
width: 200px;
}
<button class="button" style="width: 200px;"><span>Hover 1</span></button>
<button class="button" style="width: 140px;"><span>Hover 2</span></button>
<DIV>
I would like it to look something like the below after hovering
<DIV class="buttonAfter">
<SPAN style="float: left;"> Hover after </SPAN><SPAN style="float: right">►</SPAN>
</DIV>
</DIV>
我希望箭头从元素外部从右侧进入(当它溢出时隐藏,然后一旦它在元素范围内可见)并在它很好地位于框内时固定,填充 5px从右边距。我仍然希望“悬停”左对齐。
非常感谢任何帮助,在此先感谢。
【问题讨论】:
标签: css hover css-animations