G
G
Goldd lol2021-06-14 16:48:19
css
Goldd lol, 2021-06-14 16:48:19

How to make .content-head a:hover {display:block} what's wrong?

I have code

<div class='content-head'>
    <a id='phones' href='aboutthissite.html'>О сайте</a>
    <div class='content'>
    <a>1</a>
    <a>2</a>
    <a>3</a>
  </div>
  </div>

and
.content {
    display: none;
    position: absolute;
    background-color: #f1f1f1;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}
.content-head:hover .content {display: block;}
#phones {
    /*border-left: 0.1px solid #6E61E9;*/
    margin-left: 10px;
    text-decoration: none;
    color: #f6f2f1;
}
#phones:hover {
    color: #79D4E9;
}

I want .content with links to appear when hovering over a link, but it works when I hover over the entire block

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria, 2021-06-14
@Hacker2282288

.content-head:hover just works when hovering over the entire block. To work only when hovering over a link, you need to hang hover on this link
#phones:hover + .content {display: block;}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question