当用户将鼠标悬停在按钮上时,我需要显示一个信封图标。
我使用伪类before
来显示图标。当我将opacity
中的.btn-btn-envelope::before
更改为1
时,仍然看不到信封图标。
.btn-pos {
margin-top: 10px;
float: right;
}
.btn-btn {
border: none;
background-color: #502030;
color: #fff;
padding: 10px 0;
font-size: 15px;
cursor: pointer;
font-family: 'Lekton', sans-serif;
text-align: center;
display: inline-block;
position: relative;
overflow: hidden;
width: 90px;
}
.btn-btn-envelope {
transition: all 0.3s ease-in-out;
}
.btn-btn-envelope::before {
content: url('https://image.flaticon.com/icons/png/128/1034/1034138.png');
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
right: 0;
opacity: 0;
width: 15px;
height: 100%;
}
.btn-btn-envelope:hover {
text-indent: -20px;
}
.btn-btn-envelope:hover::before {
opacity: 1;
text-indent: 0px;
}
<div class="btn-pos">
<input type="submit" value="Send" class="btn-btn btn-btn-envelope">
</div>
(fiddle)