简体   繁体   中英

hovering over elements triggering another element hover. What is the problem?

Relevant html:

<div class="bottom-page">
    <p>What is <span class="carmeet">CarMeet?</span></p>
</div>

<div class="definitions">

    <span class="n1"><p><span class="carmeet1">CarMeet</span> is the number 
  one website for fans of cars, and car enthusiasts alike.</p></span>

    <span class="n2"><p><span class="style2">Find</span> riders in your 
  local area, state, region, or country. <span class="style2">Cruise</span> 
 along.</p>

    <span class="n3"><p><span class="style2">Create</span> and <span 
 class="style2">Join</span> crews to drift along with. Stay up-to-date with 
your group <span class="style2">Online</span> or on <span 
class="style2">Adventures</span>.</p></span>

    <span class="n4"><p>Actively<span class="style2"> engage</span> in the 
 community through the online <span class="style2">forum</span>.</p></span>

    <span class="n5"><p><span class="style2">Coast</span> through countless 
   <span class="style2">news articles</span> to find out what else is 
  happening in 
   the <span class="style2">world of automobiles</span>, and find what's 
  available 
 on the <span class="style2">market</span>.</p></span>


</div>

</div>

Relevant css;

.n1:hover {
  outline-style: solid;
  background-color: lightgreen;
  opacity: 0.8;
  color: black;
 }
 .n2:hover {
  outline-style: solid;
  background-color: lightblue;
  opacity: 0.8;
  color: black;
 }
.n3:hover {
  outline-style: solid;
  background-color: lightcoral;
  opacity: 0.8;
  color: black;
}
.n4:hover {
  outline-style: solid;
  background-color: lightyellow;
  opacity: 0.8;
  color: black;
 }
 .n5:hover {
   outline-style: solid;
   background-color: #9558a0;
   opacity: 0.8;
   color: black;
 }

I'm sure theres been a hundred other questions regarding the same thing, but I can't seem to find one that helps my case. When I hover over n3-n5, it triggers n2. This does not happen when hovering n1. Much appreciate, and sorry for being a noob.

n5 , n4 , and n3 all use the class style2 in their children. Create different classes for each child span to have separate hover effects.

not close span tag on <span class="n2">

<span class="n2"><p><span class="style2">Find</span> riders in your 
  local area, state, region, or country. <span class="style2">Cruise</span> 
 along.</p></span>

You are missing one closing span on second one:

I have done the changes, please check also make span display:block;

<div class="bottom-page">
    <p>What is <span class="carmeet">CarMeet?</span></p>
</div>

<div class="definitions">

    <span class="n1"><p><span class="carmeet1">CarMeet</span> is the number 
  one website for fans of cars, and car enthusiasts alike.</p></span>

    <span class="n2"><p><span class="style2">Find</span> riders in your 
  local area, state, region, or country. <span class="style2">Cruise</span> 
      along.</p></span>

    <span class="n3"><p><span class="style2">Create</span> and <span 
 class="style2">Join</span> crews to drift along with. Stay up-to-date with 
your group <span class="style2">Online</span> or on <span 
class="style2">Adventures</span>.</p></span>

    <span class="n4"><p>Actively<span class="style2"> engage</span> in the 
 community through the online <span class="style2">forum</span>.</p></span>

    <span class="n5"><p><span class="style2">Coast</span> through countless 
   <span class="style2">news articles</span> to find out what else is 
  happening in 
   the <span class="style2">world of automobiles</span>, and find what's 
  available 
 on the <span class="style2">market</span>.</p></span>


</div>

</div>





.definitions > span {
  display: block;
}

.n1:hover {
  outline-style: solid;
  background-color: lightgreen;
  opacity: 0.8;
  color: black;
}

.n2:hover {
  outline-style: solid;
  background-color: lightblue;
  opacity: 0.8;
  color: black;
}

.n3:hover {
  outline-style: solid;
  background-color: lightcoral;
  opacity: 0.8;
  color: black;
}

.n4:hover {
  outline-style: solid;
  background-color: lightyellow;
  opacity: 0.8;
  color: black;
}

.n5:hover {
  outline-style: solid;
  background-color: #9558a0;
  opacity: 0.8;
  color: black;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM