gpt4 book ai didi

html - 将链接文本向左移动并在悬停时显示图像

转载 作者:太空宇宙 更新时间:2023-11-04 00:59:30 25 4
gpt4 key购买 nike

考虑以下 HTML:

<div class="link-container">
<a class="link" href="workshops.php">More workshops</a>
<img src="arrow.png">
</div>

预期结果:

  • a 元素文本在 hover 上向左移动一点,并在 的右侧显示 img 元素>一个元素
  • 只有文本在悬停时向左移动
  • 图像淡入

我如何实现这一目标?

最佳答案

这是完成您要求的工作的代码片段

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>

div:hover
{
left: -10px;
position: relative;
}

a{
position: relative;
padding-left: 20px;
}

a:after {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAPFBMVEX///8AAABxcXEGBgaamprS0tLPz89aWlpWVlbT09NRUVFVVVVZWVldXV1OTk7W1ta2traWlpZGRkaCgoJyyOvBAAACf0lEQVR4nO3dC3KCMBhFYf8+1L5sbfe/14ZxmIoIJLE2vdfzbaCcCY8gkK5WAAAAAAAAAAAAAAAAAAAAAAAAaOpj3XoLrm0fm8fW23BdDxHx/N56K66pKwzrcTwURrzZHo99oW/jT2HE1nJfPS5M55yn1tvz+4aFjvvqaWFqNNtXx4Vu145zhV5zgPOFEa824zhV6HPOmS50aZwr9JgDzBc6zAGWCvX31eVC9TlATqH2HCCvMGInOwfILdSdA+QXqp5zSgo1G8sKI17kro+lhXpzgPLCdM6R2ldrCi+bA9z9sc+qwkvGsfIPNrCrPB7vW294gbp7K6XCNF+t2Fe1CmvmAGqF6fpYuK/qFaZzTlGjYmHZtUOzsOSco1qYP466hbnHo3JhurfKGEftwpzjUb1wuVG/MM0BZhsdCufvOzwK033H5Di6FE4fjz6FU+PoVHj+ePQqPDcHcCscH49+haeNjoXDOYBn4fF9h2vhz7XDt7C/R3YuPFw7vAsjvswLt+Zj6H4cup9Ld2vv6+Hxsw3HQvd56elv4W6F4+fEXoXu9/juv9O4/9Y2/azNo3DuOZtD4fwzNv1C92dP7s8Pp5/HeBTmvcunW+j+Lob7+zTu70S5v9f2Yv5uovv7pe7vCOdc38dab3W+2u/1/L+3+Gt138zUHH+t1BQq9dUUll3f2+P7wyH3b0i1jr8e33L3dNfkyStUHb8O62Jor4nRWVyfRrxvqbD0/v0/uuV1ojz6bne9Nt3r+9gtrpvocvz1Tgu9xq8zLNS7v102WEfYsG+wFrTd/nlwK+t5byz3zwP/dfX31uPX8f//FgAAAAAAAAAAAAAAAAAAAAAAAP/cN+LxOzmMTdyOAAAAAElFTkSuQmCC);
display: block;
position: absolute;
left: 234px;
top: -30px;
opacity: 0;
transition: opacity 0.1s ease-out 0s;
}

a:hover:after {
transition: opacity 1.5s ease-out 0s;
opacity: 1;
}

</style>
</head>
<body>

<div class="link-container">
<a class="link" href="workshops.php">More workshops</a>
</div>

</body>
</html>

注意:您可以根据以下语法调整 transition 值以设置淡入和淡出 [nice reference here ]:

transition:<property> <duration> <timing-function> <delay>;

关于html - 将链接文本向左移动并在悬停时显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53798287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com