on hover background image |
This is a discussion on on hover background image within the CSS forums, part of the Development category; i am using the following code to show a background image when the mouse moves on a div <div class="logobg"> ... |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Member Join Date: Sep 2009
Posts: 169
Thanks: 0
Thanked 0 Times in 0 Posts
![]() Expertise: Total Beginner Experience: Basic / None |
i am using the following code to show a background image when the mouse moves on a div <div class="logobg"> </div><!-- logobg ends --> .logobg{ float: left; width: 736px; height: 384px; background: url(logo.jpg) no-repeat 0px 0px; } .logobg:hover{ float: left; width: 736px; height: 384px; background: url(logorollover.jpg) no-repeat 0px 0px; } this is working fine in all browsers except for ie6 in ie 6 when i move the mouse over the logogb div the logorollover.jpg does not appear i have tried the following <div class="logobg"> <!--[if IE 6 ]> <div id="logo"> <img src="assets/img/logo.jpg" id="logoie" onmouseover="over()" onmouseout="out()"> </div> <![endif]--> </div><!-- logobg ends --> function over(){ document.getElementById("logoie").src="logorollove r.jpg"; } function out(){ document.getElementById("logoie").src="logo.jpg"; } also tried using function over(){ var imgsrc=document.getElementById("logoie").getAttrib ute("src"); document.getElementById("logoie").setAttribute("sr c", "logorollover.jpg"); } function out(){ var imgsrc=document.getElementById("logoie").getAttrib ute("src"); document.getElementById("logoie").setAttribute("sr c", "logo.jpg"); } the image is not changing in ie6 please advice thanks |
| | |
| | #2 |
![]() Join Date: Dec 2008
Posts: 700
Thanks: 0
Thanked 37 Times in 37 Posts
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Expertise: Design & Graphics Experience: Professional |
ie6 only acknowledges the :hover pseudo class on <a> tags. You could replace the div with an a tag, and style in css to behave like a div (display: block, margin, padding, width, height etc etc).
__________________ Jon Warner Web Pro Cafe :: The PixelForge :: Follow my Twits (or something) :: LinkedIn |
| | |
| | #3 |
| Member Join Date: Sep 2009
Posts: 169
Thanks: 0
Thanked 0 Times in 0 Posts
![]() Expertise: Total Beginner Experience: Basic / None |
thanks for replying i have tried the following <div class="logobg"> <!--[if IE 6 ]> <a class="logoie6"> <div id="logo"> <img src="assets/img/logo.jpg"> </div> </a> <![endif]--> </div><!-- logobg ends --> #logo{ float: left; width: 736px; height: 384px; background: url(../assets/img/logo.jpg) no-repeat 0px 0px; } a.logoie6{ display:block; width: 736px; height: 384px; } a.logoie6:hover div { background: url(../assets/img/logorollover.jpg) no-repeat 0px 0px; } the image does not appear on hover can this be done using javascript on mouseover and onmouseout as i mentioned in the earlier post thanks |
| | |
| | #4 |
![]() Join Date: Dec 2008
Posts: 700
Thanks: 0
Thanked 37 Times in 37 Posts
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Expertise: Design & Graphics Experience: Professional |
There's a bunch of stuff regarding whatever:hover here: Whatever:hover I'd read it myself, but I have a headache after trying to ;) you'll see what I mean.
__________________ Jon Warner Web Pro Cafe :: The PixelForge :: Follow my Twits (or something) :: LinkedIn |
| | |
| | #5 |
![]() Join Date: Feb 2010 Location: Varna, Bulgaria
Posts: 50
Thanks: 0
Thanked 11 Times in 11 Posts
![]() Expertise: Web Development Experience: Professional |
I would advice you to use 'h1' for your logo and 'a'. SEO friendly and no problems. Code: <h1 id="logo"><a href="#">Site Name</a> Code: h1#logo { float: left; display: inline; height: 100px; width: 100px; }
h1#logo a { display: block; height: 100px; background: url(images/logo.gif); }
h1#logo a:hover { background: url(images/logo-hover.gif); }
|
| | |
![]() |
| Tags |
| background, hover, image |
| Thread Tools | |
| Display Modes | |