How to change a div element and its child elements at the same time when hovering?

Issue

I have a div element, containing a table with one tr and two th. In the first th is an image and in the second a paragraph.
When I hover over the div, its color changes and when I hover over the paragraph, its color changes too.
But I want them to change simultaneously when I hover over either one of them.

Code:

/* DIV */
.about_us_table{
    box-shadow: 0px 0px 15px rgba(245, 244, 244, 0.8);
    margin: 0px auto;
    background-color: rgba(245, 244, 244, 1);
    width: 95%;
    border: 1px solid black;
    border-radius: 10px;
    transition: all 0.7s ease 0s;
}

.about_us_table:hover{
    box-shadow: 0px 0px 30px rgba(139, 0, 0, 0.8);
    margin: 0px auto;
    background-color: rgba(139, 0, 0, 0.8);
    width: 95%;
    border: 1px solid;
    border-radius: 10px;
}

/* PARAGRAPH */
#about_us_table_p{
    color: rgba(0, 0, 0, 1);
    font-size: 23px;
    transition: all 0.7s ease 0s;
}

#about_us_table_p:hover{
    color: rgba(245, 244, 244, 0.8);
}
<div class="about_us_table">
  <table border="0px" cellspacing="15px">
    <tr>
      <th align="left" style="width: 50%;">
        <img src="./img/table_1.png" width="90%" height="100%" id="table_img_1">
      </th>
      <th align="left">
        <p id="about_us_table_p">
          text
        </p>
      </th>
    </tr>
  </table>
</div>

Solution

Just add this code:

.about_us_table:hover  #about_us_table_p{
    color: rgba(245, 244, 244, 0.8);
}

this command help you

Answered By – Behnam Asaei

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published