A
A
Alexander2021-06-16 15:43:46
css
Alexander, 2021-06-16 15:43:46

How to make a hover effect on a link image with a description?

Hello, I have a beginner question. Here is a piece of HTML code:

<div id="container">
        <div id="left"><a href="#"><img src="" alt=""><span class="texthover">Какой-то текст</span></a></div>
</div>

The div with id "left" contains a link containing an image and some text in a span tag.

It is necessary to make it so that when you hover over a link (that is, an image or text under it), for example, the color of the text in the span changes, and the image, for example, is darkened.

I tried like this:
#container > div > a:hover
{
    color: #3a3f5d;
    transition: 0.5s;
}

#container > div > a > img:hover
{
    opacity: 1;
}


The text changes color, but the picture does not change. Help me fix it please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Markov, 2021-06-16
@AlexB_49

#container > div > a:hover > span {
    color: #3a3f5d;
    transition: 0.5s;
}

#container > div > a:hover > img {
    opacity: 1;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question