Results 1 to 2 of 2

Thread: hover over parent div does not affect child divs

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default hover over parent div does not affect child divs

    I am trying to hover over a parent div to change the background-color of that div, but I feel like the children are getting in the way. Here is a basic example of the code I am using:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <HTML>
    <style type="text/css">
    .a1{clear:left;width:95%;}
    .a1:hover{background-color:tan;}
    .a2{float:left;padding-left:5px;width:30%;}
    .a2:hover{background-color:red;}
    </style>
    <div class='a1'><div class='a2'>test</div><div class='a2'>test</div></div>
    </HTML>
    I want to be able to hover over test and have both divs turn tan or red.

    any ideas?
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    For some reason changing it from "clear" to "float" for .a1 fixed the problem.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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