Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Apr 2016
    Location
    UK
    Posts
    8
    Member #
    53777

    Row Highlight with Hover when including some Rowspan=2 Cells

    I have a table with some ROWSPAN. If I hover over one of the two rows (where not rowspan'd) only that sub-row of the overall double-row shows the Hover Highlight. Is there a CSS way around this with some sort of Child / Parent setting?

    Fiddle: https://jsfiddle.net/c49t6gkp/

    Code:
    <style>
    .myTableHover tr:hover td,
    .myTableHover tr:hover th
    {background-color: #FFFF99;}
    </style>
    
    <tr><td rowspan=2>Row1 Col1</td><td>Row1 Col2</td><td>Row1 Col3</td></tr>
    <tr><td>Row2 Col2</td><td>Row2 Col3</td></tr>
    Screen grabs showing mouse over First and Second sub-rows

    RowSpanHover1.jpg

    RowSpanHover2.jpg

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    You could use adjacent sibling combinator selectors (say that ten times fast!) I'm not sure if this will work, though:
    Code:
    .myTable tr:nth-child(odd) + tr {your row stuff here}
    https://css-tricks.com/child-and-sibling-selectors/ <-- this article explains the concept pretty well.

    EDIT: I'm not sure what you'd do with the even-numbered rows, though. Sibling selectors only work with elements following an element, not preceding one. You may have to rethink your logic using unordered lists and divs and put the hover effect on a containing element.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Junior Member
    Join Date
    Apr 2016
    Location
    UK
    Posts
    8
    Member #
    53777
    Not solved this, as yet, but I had an idea (not tried it yet).

    In the core-code which merges the data with a template to generate the Table/Grid I have a "row ID". This changes per "physical data row", so would be the same value for each child-row in the TABLE. So perhaps if I include this in the generated HTML I could use JQuery to highlight the row being hovered - which would then include and child rows etc - might that be a runner?

    Code:
    <tr class="ID00001"><td rowspan=2>Row1 Col1</td><td>Row1 Col2</td><td>Row1 Col3</td></tr>
    <tr class="ID00001"><td>Row2 Col2</td><td>Row2 Col3</td></tr>
    <tr class="ID00002"><td rowspan=2>Row3 Col1</td><td>Row3 Col2</td><td>Row3 Col3</td></tr>
    <tr class="ID00002"><td>Row4 Col2</td><td>Row2 Col4</td></tr>

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    In theory, it could. It's not a perfect solution (since not everyone enables Javascript and since jQuery can be bloated), but for those cases where a row class is hovered over, you could trigger the "hover" effect for the other elements containing that class.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Junior Member
    Join Date
    Apr 2016
    Location
    UK
    Posts
    8
    Member #
    53777
    Quote Originally Posted by TheGAME1264 View Post
    (since not everyone enables Javascript and since jQuery can be bloated)
    This APP is for an office Intranet, and already makes use of JQuery for other effects, so both those aspects will be OK - but its a good point and a useful reminder for me if I needed to achieve the same effect on a public-facing website


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:13 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com