Jump to content

class problem


robert_gsfame

Recommended Posts

I have this <a href="aaa.php" class="pagination">a</a>

 

.pagination{border:1px solid #CCCCCC; display:block;float:left; margin-left:2px;padding-left:4px; padding-right:4px;padding-top:2px;padding-bottom:2px;}

 

how to create the hover effect so that once the cursor touch the text, then the box background will turn from #CCCCCC into #990000

 

I have the problem with the padding as it prevents me from getting the hover effect perfectly

Link to comment
Share on other sites

There's a JavaScript approach and a CSS approach.

 

JavaScript:

Give the <A> tag an ID attribute. Let's call it "PaginationHyperlink". Then use the mouseover event.

document.getElementById("PaginationHyperlink").mouseover = function () { this.parentNode.bgColor = '#990000'; }

(Not tested)

 

CSS:

Assuming the parent node is a DIV...

div .PaginationHyperlink:hover {
     background-color: #990000 !important;
}

Link to comment
Share on other sites

Why can't we do it with the :hover selector  ::)

 

CSS:

        .pagination{
          border:1px solid #CCCCCC;
          margin-left:2px;
          padding:2px 4px;
          display:block;
          float:left;
        }
        .pagination:hover {
          background-color:#990000;
        }
        .what {
          float:left;
        }

 

HTML:

<div class="what">I have this</div><a href="aaa.php" class="pagination">a</a>

 

You need to watch out when you float just the anchor tag in FF and IE8 as it will end up before the text.

 

So that's why the div is there around your primary text which is floated too..

 

Does that help?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.