Hi all - trying to change div's background upon hover. It works in FF. Thanks, I've tried the below: .block { width: 200px; height: 200px; background-color: #FDF1D7; border: 1px solid #FFAE00; } .block a { display: block; width: 100px height: 100px;} .block a:hover {background-color: #DD6E05;} .block:hover{ background-color: #DD6E05; Code (markup):
In such a case what i use JQuery Javascript library for ease of use. Add these in your <head> part : <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="main.js"></script> HTML: (Folder/file names can be changed as per your case) Now in main.js write this : $(document).ready(function(){ $('.block'):hover( function() { $(this).addClass('active'); }, function() { $(this).removeClass('active'); } ); }); HTML: And in CSS add this : .block:hover, .blockHover { background-color: #DD6E05; } HTML:
Sweet - thanks guys for the replies, I googled .htc and got reviews 007c. The example is awesome markupdude
Sweet - thanks guys for the replies, I googled .htc and got reviews 007c. The example is awesome markupdude
.htc hands down. For the sake of everybody who likes sites to load the same day they open them, do not use Jquery.
You can only apply hover effects to anchor elements in most versions of internet explorer, but I did not know about the css behavior file that you guys mention, I just use a Javascript solution most of the time.
++rochow. The .htc is the way to go. Yes, it is still dependent on the browser supporting JS, but it's a nice file that sits unobtrusively on your server. Copy-pasta. Check out the page: http://www.xs4all.nl/~peterned/csshover.html and the code (you can just copy-paste, stuff on your server, and add the single CSS line for IE6): http://www.xs4all.nl/~peterned/htc/csshover3.htc