0

The code below shows the use of a sprite that should normally display images in B&W and when the mouse is hovered over the images, they become colored, but without showing the transitions between the images. It would only change color.

What can be done to not show the transitions?

This appears in the sidebar of our website:

https://materiaincognita.com.br/

The code is in this text file as follows:

<head>
<style>

#social {
    position: relative;
    padding: 0px 5px 0px;
}

#social li, #social a {
    display: inline-block;
    position: relative;
    width: 60px;
    height: 56px;
}

#facebook {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -0 -0;
}

#pinterest {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -60px -0;
}

#bluesky {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -120px -0;
}

#youtube {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -180px -0;
}

#instagram {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -240px -0;
}

#facebook a:hover {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -0 -60px;
}

#pinterest a:hover {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -60px -60px;
}

#bluesky a:hover {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -120px -60px;
}

#youtube a:hover {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -180px -60px;
}

#instagram a:hover {
    left: 0px;
    background: url('https://materiaincognita.com.br/wp-content/uploads/2024/11/redes-sociais.jpg') -240px -60px;
}

</style>
</head>
<body>
<div id="social">
<ul>
<li id="facebook"><a title="Facebook" href="https://www.facebook.com/materia.incognita" target="_blank" rel="noopener"></a></li>
<li id="pinterest"><a title="Pinterest" href="https://br.pinterest.com/materiaincog" target="_blank" rel="noopener"></a></li>
<li id="bluesky"><a title="Bluesky" href="https://bsky.app/profile/materia-incognita.bsky.social" target="_blank" rel="noopener"></a></li>
<li id="youtube"><a title="YouTube" href="https://www.youtube.com/user/materiaincognita" target="_blank" rel="noopener"></a></li>
<li id="instagram"><a title="Instagram" href="https://www.instagram.com/materia.incognita/" target="_blank" rel="noopener"></a></li>
</ul>
</div>
</body>

However, if I put my code in "CodePen dot io" it works perfectly as I want.

The problem seems to be inside WordPress system…

Any idea to solve the problem?

3
  • Inspect your site where the problem is occurring, and look for any transition style rules, then add your own rules to overwrite those (assuming they're in a default style and you can't just remove them) Commented Nov 28, 2024 at 16:22
  • You need to add the CSS rule #social a, #social a:hover { transition:none !important; } like Johanes explains below. Also, there are some misalignment to adjust on the Y axis for your sprites when hovered: The hovered values for Y axis are -58px for all, instead of -60px (except for #instagram a:hover which correct value is -57px). Commented Nov 28, 2024 at 16:44
  • Hi, DBS and LoicTheAztec. Thanks for your replies. I've changed the height of the image and aligned it better. Everything is perfect now. Thank you again!!! Commented Dec 1, 2024 at 22:41

1 Answer 1

0

There is a css rule for a in your website that contains transition settings.

To avoid the transition, add transition: none; to the css rule for #social a. If that still doesn't work, add !important, i.e. transition: none !important;

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Johannes. Everything is OK now! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.