Create 2 elements influencing the same CSS

Asked

Viewed 73 times

2

You can create a hover effect with two elements influencing one in common ?

for example:

#div:hover "ou" #div2:hover = #elemento{display:block;} 

I made myself clear ?

  • 1

    I get the feeling that this #elemento can be "illegal". What I mean is that you cannot have two different elements with the same ID on the same page. If it is not the case ignore me :)

1 answer

5


I think I got it. You can define a same set for two or more rules, separating them with commas:

#div:hover #elemento,
#div2:hover #elemento
{
    display:block;
} 

In case I got it wrong, feel free to add more information to your question. =)

  • Cool, that was exactly my question..

  • @If it was answered correctly as a request, it would be possible to mark as the correct answer so that other people who have the same problem in the future know the correct answer to the question ?

  • It is not good practice, could have done the same thing using a class, more suitable for more than one element.

  • @Marceloaymone you are correct in your analysis, and it is a valid comment for the user to produce a code with higher quality. However, the point of the answer was to demonstrate the application of the same set of rules for two scopes.

  • @Douglasbernadino, I answered up there. Yes, he answered my question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.