Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts

    Can a single a:hover effect multiple anchors?

    Does anyone have a CSS solution for this. I'm sure this would be very do-able with JS, but I'd much rather do it in CSS if it's possible.
    Here's my starting point:
    Code:
    <STYLE>
      li.a1 a:hover{font-weight:bold}
      li.z9 a:hover{font-weight:bold}
    </STYLE>
    <ul>
      <li class="a1"><a href=#>ABC123</a></li>
      <li class="z9"><a href=#>XYZ789</a></li>
    </ul>
    <p>jhkjudsis duisdh udishuisdh agqia du ahauli.</p>
    <ul>
      <li class="a1"><a href=#>abc123</a></li>
      <li class="z9"><a href=#>xyz789</a></li>
    </ul>
    I'm hoping that both links of the same class can get effected by hovering over either one.

    ~ Mo

    NOTE: I know bold on hover is not advised for space/shifting reasons, but that's really the issue here.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,624
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Nope, not possible with CSS. CSS is the abbreviation for cascading stylesheet with the emphasis on “cascading” which means that CSS can style elements that are related to each other in a descending fashion (or on the same level). And by related to each other I mean parent>child or sibling relationships. So, in a nutshell: You can style child or sibling elements differently by hovering over a parent or sibling, respectively, but you can’t style a parent element by hovering over the child, or a sibling of a parent by hovering over a child. In other words: A cascade can only go down (or sidewards), not upwards.

    However, with a simple JavaScript all your dreams could become reality. You’d just need getElementsByClass and apply a style to all returned elements on mouseover of any one of the returned elements.

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts

    Resolved!

    I was afraid of that .

    Thanks-a-bunch.

    ~ Mo


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •