-1

please take a look at this fiddle :

http://jsfiddle.net/cX47v/1

I am simply trying to preserve the effect that you see, but i want to remove the white space below the image. I know about display:block, but if i do it, the hover effect does not work. Any ideas on how to fix that ?

ToddBFisher
  • 11,080
  • 8
  • 36
  • 51
Spyros
  • 43,914
  • 23
  • 83
  • 124

3 Answers3

3

Changing the HTML to what I have below (adding the style="font-size:0") fixes the issue in Chrome, Firefox, IE9 and Safari. I've seen this issue before where a browser assumes one row of text as some extra height, even where there is no visible text.

<div class='fancy_image'>
    <div class='shadow' style='border:2px solid; float:left;padding:5px;margin:10px;'>
        <div style="font-size: 0;">    
            <img class='fade' src="http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg" width=300 height=200  />
        </div>
    </div>
</div>

enter image description here

You can see it work here: http://jsfiddle.net/jfriend00/8FkmG/. The remaining white space around the image is controlled by the padding in your HTML.

Overall, your HTML/CSS is really screwy here mixing float and positioning and doing positioning on a span. Very odd.

jfriend00
  • 637,040
  • 88
  • 896
  • 906
  • both answers work great thank you guys :) It would be nice to know what css part is screwy also. I don't have any span or positioning in my example and if i don't use a float the effect will not work. Is there something the can be done better here ? Just out of curiosity, thanx for the solution anyway :) – Spyros Dec 16 '11 at 05:33
  • Where did the javascript code come from? Using different CSS for different browsers is not necessary for such a simple layout and is likely a maintenance headache. – jfriend00 Dec 16 '11 at 05:47
  • ah you are talking about the javascript ? this is a ready made script so ok :P – Spyros Dec 16 '11 at 06:46
1

Set line-height:0; in your shadow div.

WrightsCS
  • 50,205
  • 22
  • 134
  • 184
ToddBFisher
  • 11,080
  • 8
  • 36
  • 51
0

just changes the .fade css class

.fade {font-size:0px;
    background: url('http://james.linnegar.com/demos/js/win7/hover.png');
}
Murtaza
  • 3,025
  • 2
  • 24
  • 39