gpt4 book ai didi

html - :hover? 上闪烁的 svg 组

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

当鼠标悬停在我的 svg 上时,我试图让“HI”svg 组消失并显示“BYE”形状。相反,它在两组之间快速闪烁 - 我不确定我是否搞砸了分组或其他什么,但我们将不胜感激。

        svg { height: 30vw; display: block; margin: auto;}

.section:hover #bye.show { display: block; }
.section:hover #hi.hide { display: none; }
<body>       

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 360 360">

<a class="section" xlink:href="https://google.com" target="_blank">
<g id="bye" class="show">
<g>
<rect x="48.685" y="51.107" fill="#00AEEF" width="262.63" height="257.785"/>
<path d="M154.537,168.045c1.444-0.304,3.723-0.531,6.041-0.531c3.306,0,5.433,0.569,7.029,1.861
c1.33,0.988,2.128,2.508,2.128,4.521c0,2.47-1.634,4.635-4.332,5.623v0.076c2.432,0.607,5.281,2.621,5.281,6.421
c0,2.204-0.874,3.875-2.166,5.129c-1.786,1.634-4.673,2.394-8.853,2.394c-2.279,0-4.027-0.151-5.129-0.304V168.045z M157.842,178.531h3.002c3.495,0,5.547-1.823,5.547-4.293c0-3.002-2.28-4.18-5.623-4.18c-1.52,0-2.394,0.114-2.926,0.229V178.531z M157.842,190.804c0.646,0.114,1.596,0.152,2.774,0.152c3.419,0,6.573-1.254,6.573-4.978c0-3.495-3.001-4.939-6.611-4.939h-2.736
V190.804z M180.262,193.312v-10.866l-8.093-14.742h3.761l3.609,7.067c0.988,1.938,1.748,3.495,2.546,5.281h0.076
c0.722-1.672,1.596-3.344,2.583-5.281l3.686-7.067h3.762l-8.587,14.704v10.904H180.262z M208.114,181.306h-9.954v9.232h11.094v2.773h-14.399v-25.608h13.83v2.773H198.16v8.093h9.954V181.306z"/>
</g>
</g>
</a>

<a class="section" xlink:href="https://google.com" target="_blank">
<g id="hi" class="hide">
<g>
<rect x="48.685" y="51.107" fill="#ED1C24" width="262.63" height="257.785"/>
<path d="M170.42,167.703v10.715h12.387v-10.715h3.343v25.608h-3.343v-12.006H170.42v12.006h-3.305v-25.608H170.42z"/>
<path d="M195.196,167.703v25.608h-3.306v-25.608H195.196z"/>
</g>
</g>
</a>
</svg>
</body>

最佳答案

只保持悬停并将其应用于 svg 而不是 .section

svg {
height: 30vw;
display: block;
margin: auto;
}

svg:hover #hi.hide {
display: none;
}
<body>

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 360 360">

<a class="section" xlink:href="https://google.com" target="_blank">
<g id="bye" class="show">
<g>
<rect x="48.685" y="51.107" fill="#00AEEF" width="262.63" height="257.785"/>
<path d="M154.537,168.045c1.444-0.304,3.723-0.531,6.041-0.531c3.306,0,5.433,0.569,7.029,1.861
c1.33,0.988,2.128,2.508,2.128,4.521c0,2.47-1.634,4.635-4.332,5.623v0.076c2.432,0.607,5.281,2.621,5.281,6.421
c0,2.204-0.874,3.875-2.166,5.129c-1.786,1.634-4.673,2.394-8.853,2.394c-2.279,0-4.027-0.151-5.129-0.304V168.045z M157.842,178.531h3.002c3.495,0,5.547-1.823,5.547-4.293c0-3.002-2.28-4.18-5.623-4.18c-1.52,0-2.394,0.114-2.926,0.229V178.531z M157.842,190.804c0.646,0.114,1.596,0.152,2.774,0.152c3.419,0,6.573-1.254,6.573-4.978c0-3.495-3.001-4.939-6.611-4.939h-2.736
V190.804z M180.262,193.312v-10.866l-8.093-14.742h3.761l3.609,7.067c0.988,1.938,1.748,3.495,2.546,5.281h0.076
c0.722-1.672,1.596-3.344,2.583-5.281l3.686-7.067h3.762l-8.587,14.704v10.904H180.262z M208.114,181.306h-9.954v9.232h11.094v2.773h-14.399v-25.608h13.83v2.773H198.16v8.093h9.954V181.306z"/>
</g>
</g>
</a>

<a class="section" xlink:href="https://google.com" target="_blank">
<g id="hi" class="hide">
<g>
<rect x="48.685" y="51.107" fill="#ED1C24" width="262.63" height="257.785"/>
<path d="M170.42,167.703v10.715h12.387v-10.715h3.343v25.608h-3.343v-12.006H170.42v12.006h-3.305v-25.608H170.42z"/>
<path d="M195.196,167.703v25.608h-3.306v-25.608H195.196z"/>
</g>
</g>
</a>
</svg>
</body>

关于html - :hover? 上闪烁的 svg 组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51616717/

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