gpt4 book ai didi

html - 这个网站如何让他们的巴士图标在悬停时移动?

转载 作者:太空宇宙 更新时间:2023-11-03 23:03:35 24 4
gpt4 key购买 nike

在万维网上。 www.coachella.com他们有这些穿梭巴士图标,其中 3 个,并且在悬停时图标会四处移动。我怎样才能为我的网站做这样的事情?有没有指南?

我查看了源代码,它非常困惑,但看起来它们有 3 个 svg 标签,并且它们在悬停时是动画的。普通人的工作有多难?

<div id="icon-shuttles" class="icon">
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="icon-shuttles-base-1" class="absolutePosition" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 305.8 350.7" style="transform-origin: 100% 50% 0px; transform: matrix(1, 0, 0, 1, 0, 0);" xml:space="preserve">
<style type="text/css">
.st0-shuttles{fill:#FCFCFC;}
.st1-shuttles{fill:#FCA126;}
.st2-shuttles{fill:#CB821F;}
</style>
<rect x="25.6" y="50" class="st0-shuttles" width="255" height="154.5"></rect>
<path class="st1-shuttles" d="M28.3,154.5c0.4-15.2,0.8-30.3,1.2-45.4c0.1-2.5,0.1-5.1,0.2-7.6C30,91.3,30.4,81.2,30.5,71
c0-7.4,6.4-10.6,13.9-12.1c6.8-1.3,14.5-1.2,19.1-1.4c12.7-0.6,25.4-0.8,38.1-1.1c17-0.3,34.1-0.4,51.4-0.4V35.3h-24.1
c-5.5,0-10-4.5-10-10V25c0-5.5,4.5-10,10-10H153V0H37C20.5,0,7,13.5,7,30L6.2,56.7L4.9,99.9L1.7,209.3l-1,32.8l-0.3,8.8l-0.3,10.9
L0,265.4c0,7.2,2.6,15.7,6.8,23c0.8,1.4,1.7,2.7,2.6,4c1.5,2,3,3.9,4.7,5.5c0.2,0.2,0.3,0.3,0.5,0.5v44.1c0,4.4,3.6,8,8,8h40
c4.4,0,8-3.6,8-8v-23.2h82.2v-14v-35.2l0,0v-67.6c-8.1,0-16.1-0.1-24.2-0.2c-15.6-0.2-31.2-0.3-46.7-1.2c-7.1-0.4-14.1-0.9-21.1-1.7
c-5.4-0.7-10.9-1.5-16.3-2.7c-1.1-0.2-2.2-0.5-3.3-0.8c-2.8-0.8-5.5-1.9-7.8-3.6c-6.8-4.9-5.9-12.5-5.7-20
C28,166.5,28.1,160.5,28.3,154.5z"></path>
<path class="st2-shuttles" d="M277.6,154.5c-0.4-15.2-0.8-30.3-1.2-45.4c-0.1-2.5-0.1-5.1-0.2-7.6c-0.3-10.2-0.7-20.3-0.8-30.5
c0-7.4-6.4-10.6-13.9-12.1c-6.8-1.3-14.5-1.2-19.1-1.4c-12.7-0.6-25.4-0.8-38.1-1.1c-17-0.3-34.1-0.4-51.4-0.4V35.3H177
c5.5,0,10-4.5,10-10V25c0-5.5-4.5-10-10-10h-24.1V0h115.9c16.5,0,30,13.5,30,30l0.8,26.7l1.3,43.2l3.2,109.4l1,32.8l0.3,8.8
l0.3,10.9l0.1,3.6c0,7.2-2.6,15.7-6.8,23c-0.8,1.4-1.7,2.7-2.6,4c-1.5,2-3,3.9-4.7,5.5c-0.2,0.2-0.3,0.3-0.5,0.5v44.1
c0,4.4-3.6,8-8,8h-40c-4.4,0-8-3.6-8-8v-23.2H153v-14v-35.2l0,0v-67.6c8.1,0,16.1-0.1,24.2-0.2c15.6-0.2,31.2-0.3,46.7-1.2
c7.1-0.4,14.1-0.9,21.1-1.7c5.4-0.7,10.9-1.5,16.3-2.7c1.1-0.2,2.2-0.5,3.3-0.8c2.8-0.8,5.5-1.9,7.8-3.6c6.8-4.9,5.9-12.5,5.7-20
C277.9,166.5,277.7,160.5,277.6,154.5z"></path>
<circle class="st0-shuttles" cx="55.6" cy="251" r="26.5"></circle>
<circle class="st0-shuttles" cx="250.6" cy="251" r="26.5"></circle>
</svg>

<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="icon-shuttles-base-3" class="absolutePosition" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 305.8 350.7" style="transform: matrix(1, 0, 0, 1, 0, 0); transform-origin: 0% 50% 0px;" xml:space="preserve">
<style type="text/css">
.st0-shuttles{fill:#FCFCFC;}
.st1-shuttles{fill:#FCA126;}
.st2-shuttles{fill:#CB821F;}
</style>
<rect x="25.6" y="50" class="st0-shuttles" width="255" height="154.5"></rect>
<path class="st1-shuttles" d="M28.3,154.5c0.4-15.2,0.8-30.3,1.2-45.4c0.1-2.5,0.1-5.1,0.2-7.6C30,91.3,30.4,81.2,30.5,71
c0-7.4,6.4-10.6,13.9-12.1c6.8-1.3,14.5-1.2,19.1-1.4c12.7-0.6,25.4-0.8,38.1-1.1c17-0.3,34.1-0.4,51.4-0.4V35.3h-24.1
c-5.5,0-10-4.5-10-10V25c0-5.5,4.5-10,10-10H153V0H37C20.5,0,7,13.5,7,30L6.2,56.7L4.9,99.9L1.7,209.3l-1,32.8l-0.3,8.8l-0.3,10.9
L0,265.4c0,7.2,2.6,15.7,6.8,23c0.8,1.4,1.7,2.7,2.6,4c1.5,2,3,3.9,4.7,5.5c0.2,0.2,0.3,0.3,0.5,0.5v44.1c0,4.4,3.6,8,8,8h40
c4.4,0,8-3.6,8-8v-23.2h82.2v-14v-35.2l0,0v-67.6c-8.1,0-16.1-0.1-24.2-0.2c-15.6-0.2-31.2-0.3-46.7-1.2c-7.1-0.4-14.1-0.9-21.1-1.7
c-5.4-0.7-10.9-1.5-16.3-2.7c-1.1-0.2-2.2-0.5-3.3-0.8c-2.8-0.8-5.5-1.9-7.8-3.6c-6.8-4.9-5.9-12.5-5.7-20
C28,166.5,28.1,160.5,28.3,154.5z"></path>
<path class="st2-shuttles" d="M277.6,154.5c-0.4-15.2-0.8-30.3-1.2-45.4c-0.1-2.5-0.1-5.1-0.2-7.6c-0.3-10.2-0.7-20.3-0.8-30.5
c0-7.4-6.4-10.6-13.9-12.1c-6.8-1.3-14.5-1.2-19.1-1.4c-12.7-0.6-25.4-0.8-38.1-1.1c-17-0.3-34.1-0.4-51.4-0.4V35.3H177
c5.5,0,10-4.5,10-10V25c0-5.5-4.5-10-10-10h-24.1V0h115.9c16.5,0,30,13.5,30,30l0.8,26.7l1.3,43.2l3.2,109.4l1,32.8l0.3,8.8
l0.3,10.9l0.1,3.6c0,7.2-2.6,15.7-6.8,23c-0.8,1.4-1.7,2.7-2.6,4c-1.5,2-3,3.9-4.7,5.5c-0.2,0.2-0.3,0.3-0.5,0.5v44.1
c0,4.4-3.6,8-8,8h-40c-4.4,0-8-3.6-8-8v-23.2H153v-14v-35.2l0,0v-67.6c8.1,0,16.1-0.1,24.2-0.2c15.6-0.2,31.2-0.3,46.7-1.2
c7.1-0.4,14.1-0.9,21.1-1.7c5.4-0.7,10.9-1.5,16.3-2.7c1.1-0.2,2.2-0.5,3.3-0.8c2.8-0.8,5.5-1.9,7.8-3.6c6.8-4.9,5.9-12.5,5.7-20
C277.9,166.5,277.7,160.5,277.6,154.5z"></path>
<circle class="st0-shuttles" cx="55.6" cy="251" r="26.5"></circle>
<circle class="st0-shuttles" cx="250.6" cy="251" r="26.5"></circle>
</svg>

<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="icon-shuttles-base-2" class="absolutePosition" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 305.8 350.7" style="enable-background:new 0 0 305.8 350.7;" xml:space="preserve">
<style type="text/css">
.st0-shuttles{fill:#FCFCFC;}
.st1-shuttles{fill:#FCA126;}
.st2-shuttles{fill:#CB821F;}
</style>
<rect x="25.6" y="50" class="st0-shuttles" width="255" height="154.5"></rect>
<path class="st1-shuttles" d="M28.3,154.5c0.4-15.2,0.8-30.3,1.2-45.4c0.1-2.5,0.1-5.1,0.2-7.6C30,91.3,30.4,81.2,30.5,71
c0-7.4,6.4-10.6,13.9-12.1c6.8-1.3,14.5-1.2,19.1-1.4c12.7-0.6,25.4-0.8,38.1-1.1c17-0.3,34.1-0.4,51.4-0.4V35.3h-24.1
c-5.5,0-10-4.5-10-10V25c0-5.5,4.5-10,10-10H153V0H37C20.5,0,7,13.5,7,30L6.2,56.7L4.9,99.9L1.7,209.3l-1,32.8l-0.3,8.8l-0.3,10.9
L0,265.4c0,7.2,2.6,15.7,6.8,23c0.8,1.4,1.7,2.7,2.6,4c1.5,2,3,3.9,4.7,5.5c0.2,0.2,0.3,0.3,0.5,0.5v44.1c0,4.4,3.6,8,8,8h40
c4.4,0,8-3.6,8-8v-23.2h82.2v-14v-35.2l0,0v-67.6c-8.1,0-16.1-0.1-24.2-0.2c-15.6-0.2-31.2-0.3-46.7-1.2c-7.1-0.4-14.1-0.9-21.1-1.7
c-5.4-0.7-10.9-1.5-16.3-2.7c-1.1-0.2-2.2-0.5-3.3-0.8c-2.8-0.8-5.5-1.9-7.8-3.6c-6.8-4.9-5.9-12.5-5.7-20
C28,166.5,28.1,160.5,28.3,154.5z"></path>
<path class="st2-shuttles" d="M277.6,154.5c-0.4-15.2-0.8-30.3-1.2-45.4c-0.1-2.5-0.1-5.1-0.2-7.6c-0.3-10.2-0.7-20.3-0.8-30.5
c0-7.4-6.4-10.6-13.9-12.1c-6.8-1.3-14.5-1.2-19.1-1.4c-12.7-0.6-25.4-0.8-38.1-1.1c-17-0.3-34.1-0.4-51.4-0.4V35.3H177
c5.5,0,10-4.5,10-10V25c0-5.5-4.5-10-10-10h-24.1V0h115.9c16.5,0,30,13.5,30,30l0.8,26.7l1.3,43.2l3.2,109.4l1,32.8l0.3,8.8
l0.3,10.9l0.1,3.6c0,7.2-2.6,15.7-6.8,23c-0.8,1.4-1.7,2.7-2.6,4c-1.5,2-3,3.9-4.7,5.5c-0.2,0.2-0.3,0.3-0.5,0.5v44.1
c0,4.4-3.6,8-8,8h-40c-4.4,0-8-3.6-8-8v-23.2H153v-14v-35.2l0,0v-67.6c8.1,0,16.1-0.1,24.2-0.2c15.6-0.2,31.2-0.3,46.7-1.2
c7.1-0.4,14.1-0.9,21.1-1.7c5.4-0.7,10.9-1.5,16.3-2.7c1.1-0.2,2.2-0.5,3.3-0.8c2.8-0.8,5.5-1.9,7.8-3.6c6.8-4.9,5.9-12.5,5.7-20
C277.9,166.5,277.7,160.5,277.6,154.5z"></path>
<circle class="st0-shuttles" cx="55.6" cy="251" r="26.5"></circle>
<circle class="st0-shuttles" cx="250.6" cy="251" r="26.5"></circle>
</svg>



<div id="icon-shuttles-hit" class="icon-hit-square"></div>
</div>

最佳答案

如果您不熟悉 SVG,您可以将它们换成标准的 png 图标。可以找到有关 SVG 的一些信息 here

动画部分很简单,只需将 transform:translate3D 添加到悬停的两个公交车图标即可。

假设您有一个包含 3 个 div 的 div。每个 div 包含一个总线(可以是 svg、png、图标字体或类似的)

HTML

 <div class="buses">
<div class="bus-1"></div>
<div class="bus-2"></div>
<div class="bus-3"></div>
</div>

您的 CSS 看起来像下面这样:

CSS

.buses .bus-1,
.buses .bus-3 {
/* This determines the duration of the animation */

-webkit-transition: -webkit-transform 600ms ease;
transition: transform 600ms ease;
}

.buses:hover .bus-1 {
/* The translate property will move the bus in an x,y,z direction */

-webkit-transform: translate3D(-10px, 0, 0);
transform: translate3D(-10px, 0, 0);
}

.buses:hover .bus-3 {
/* The translate property will move the bus in an x,y,z direction */

-webkit-transform: translate3D(10px, 0, 0);
transform: translate3D(10px, 0, 0);
}

关于html - 这个网站如何让他们的巴士图标在悬停时移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35565942/

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