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 6336851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:08:11+00:00 2026-05-24T19:08:11+00:00

I am trying to apply a background image hover effect on each row in

  • 0

I am trying to apply a background image hover effect on each row in my css table but need it to appear to the left of the containing element.

View image http://www.weiserwebworld.com/images/view.gif

Any ideas?

JS:

$(function() {
    $(".table-row").hover(function() { 
        $(this).addClass("highlight");
    }, function() {
        $(this).removeClass("highlight");
    })
})

CSS:

#container {
    width: 660px; 
    margin: 20px auto;
}

div .table {
    display: table;
    border: 1px red solid;  
}
div .table-row {
    display: table-row;
}
div .table-cell {
    display: table-cell;
    width: 145px;
    padding: 10px;
    vertical-align: top;

}
.highlight {
    cursor: pointer;
    background-image: url('click-to-view.png');
    background-position: 0 center;
    background-repeat: no-repeat;

}

HTML:

<div id="container">
    <div class="table">
        <div class="table-row">
            <div class="table-cell">Ralph Kramden</div>
            <div class="table-cell">Truck Driver</div>
            <div class="table-cell">8/17/2010</div>
            <div class="table-cell">N/A</div>
        </div>
        <div class="table-row">
            <div class="table-cell">Ralph Kramden</div>
            <div class="table-cell">Truck Driver</div>
            <div class="table-cell">8/17/2010</div>
            <div class="table-cell">N/A</div>
        </div>
    </div>
</div>
  • 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-24T19:08:12+00:00Added an answer on May 24, 2026 at 7:08 pm

    First, throw away this:

    $(function() {
        $(".table-row").hover(function() { 
            $(this).addClass("highlight");
        }, function() {
            $(this).removeClass("highlight");
        })
    })
    

    It is an abomination.

    Then change the CSS selector .highlight to .table-row:hover. As you clearly don’t care about IE6 (where :hover only worked on a elements), there’s nothing wrong with using :hover.

    Now to the rest of the problem.


    The technique that I would use for this is the before or after pseudo-element. Something like this:

    .table-row {
        position: relative; /* So that the position: absolute on the "click to view" makes it relative to the table row */
    }
    .table-row:hover:after {
        position: absolute;
        left: -80px; /* Adjust as desired */
        content: url(click-to-view.png); /* This makes it an image */
    }
    

    There’s plenty of tweaking that can be done with this, but that’s the general idea. No demo on jsfiddle as I can’t be bothered doing the table structure or getting an image for it.

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

Sidebar

Related Questions

I am trying apply two background images for an entire table row. One background
I am trying to apply css for my table as show in sample 9.Table
I'm trying to apply a CSS image rollover on a Wordpress header logo. I
I'm trying to apply CSS to my <h:inputText> but without success so far :
I am trying to apply a background-image to a li element. <ul> <li class=maintablink>&nbsp;</li>
I am using CSS to apply a background image to a div tag that
I'm trying to apply a gradient background to just one row in a XAML
Im trying to apply different background color to even and odd items in a
I am trying to apply css on my html.dropdownlist with a regular html select
I am trying to apply conditional formatting of certain table cells in my ReportViewer

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.