Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:43:13+00:00 2026-05-25T06:43:13+00:00

I got a table with some top and bottom borders.. But the :hover class

  • 0

I got a table with some top and bottom borders.. But the :hover class doesn’t work as I want it to..

In some cases I got an extra class on the TD’s and when the mouse is moved over only the bottom border changes

I have made a jsfiddle here to demonstrate:

td {
    border:1px solid #99bfe3;
    border-left:0px;
    border-right:0px;
    padding:5px;
    vertical-align:top;
}

tr:hover > td {
    background:#cae5fd;
    border:1px #375877 solid;
    border-left:0px;
    border-right:0px;
}

td.test {
    background:#9deea4;
    border:1px #51a357 solid;
    border-left:0px;
    border-right:0px;
}

tr:hover > td.test {
    background:#7fda86;
    border:1px #265c2b solid;
    border-left:0px;
    border-right:0px;
}

<table>
    <tr>
        <td>cell</td>
        <td>cell</td>
    </tr>
    <tr>
        <td class="test">cell</td>
        <td>cell<br>hmm</td>
    </tr>
    <tr>
        <td class="test">cell</td>
        <td class="test">cell<br>hmm</td>
    </tr>
    <tr>
        <td>cell</td>
        <td>cell</td>
    </tr>
    <tr>
        <td>cell</td>
        <td>cell</td>
    </tr>
    <tr>
        <td>cell</td>
        <td>cell<br>hmm</td>
    </tr>
</table>

http://jsfiddle.net/VRv3f/

How can you make both the top and bottom borders to react on :hover?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:43:13+00:00Added an answer on May 25, 2026 at 6:43 am

    This might be considered cheating, but you could use a SPAN (or DIV) inside your TD.test and then deploy negative margins.

    NOTE: This will break if two cells have different heights, since the SPAN/DIV will not expand to the new calculated height of the row. The below example gets around this by setting the border on the bottom of the cell (which works fine), and then setting the top border on the negative margin SPAN within it, while zeroing out the padding top, left and right on the cell and adding it to the SPAN.

    tr > td {
        padding: 5px;
        border-bottom: 1px solid #99bfe3;
        vertical-align: top;
    }
    
    tr:hover {
        background: #cae5fd;
    }
    
    td.test {
        background: #b1f0b6;
    }
    
    tr:hover > td.test {
        padding: 0 0 5px 0;
        border-bottom: 1px solid black;
        background: #8de194;
    }
    
    tr:hover > td.test span {
        display: block;
        margin: -1px 0;
        position: relative;
        padding: 5px 5px 1px;
        border-top: 1px solid black;
    }
    
    <table>
        <tr>
            <td>cell</td>
            <td>cell</td>
        </tr>
        <tr>
            <td class="test"><span>cell</span></td>
            <td>cell<br>hmm</td>
        </tr>
        <tr>
            <td class="test"><span>cell</span></td>
            <td class="test"><span>cell<br>hmm</span></td>
        </tr>
        <tr>
            <td>cell</td>
            <td>cell</td>
        </tr>
        <tr>
            <td>cell</td>
            <td>cell</td>
        </tr>
        <tr>
            <td>cell</td>
            <td>cell<br>hmm</td>
        </tr>
    </table>
    

    http://jsfiddle.net/82bRU/18/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a table that has some <input type=text> boxes in it, and I
I'm building an iphone app and I've got a table view with some textfields
I've got some blank values in my table, and I can't seem to catch
I got a query with five joins on some rather large tables (largest table
I got a table where in got allocated space of 3gig but have no
I've got a table of URLs and I don't want any duplicate URLs. How
I want to work on some Live Updates which is rendered in an iframe.
I got a table called music with some ids: 6983887641 59088763306 116542622632 106436032725763 6750402929
I've got a table with CSS3 alternating row styles but I need to override
I've got a table with some nullable double fields. Working with LinqToSQL trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.