tags:

views:

225

answers:

2

Hello!

Why isn't the overlaying image (in nested div) fading along with the parent div? Problem only in EXPLORER..

See the 'recent' labels on the portfolio items: My website

Switch category's in the navigation to see that the 'recent' labels don't fade in Internet-Explorer

This is the html:

<div class="art recent">
   <div class="recentlabel"><img src="images/Recent-label.png" /></div>
    <a href="images/art/1.jpg" rel="lightbox" title=""> <img border="0" src="images/art/1tn.jpg" width="190" height="263" /></a><p>ARTIST<br />     artwork</p>
  </div>

This the css:

.art  {
   width: 190px;
   padding: 0px;
   margin: 5px;
   float: left;
   background:#2c313b;
   display: inline;
    -moz-border-radius: 5px;
   -webkit-border-radius: 5px;
  border-radius: 5px;
}

.recentlabel {
 position:absolute;
 margin-top:-2px;
 margin-left:97px;
 width:95px;
 height:95px;
}

.recent {
}

And this is the jquery:

var $j = jQuery.noConflict();$j(document).ready(function(){    
    $j(".art").css({opacity: 0});   // Loaded at 0 opacity
    $j(".art").fadeTo(900, 0.8);    // Onload fade items to 80%

    $j(".art").hover(function(){
  if(!$j(this).hasClass("hidden")){
    $j(this).fadeTo("fast", 1.0); }  // Rollover at 100%
    },function(){
  if(!$j(this).hasClass("hidden")){
    $j(this).fadeTo("fast", 0.8); }  // Rollout at 80%
    });
});

Please help! I can't figure it out.. PS: I have little experience with jQuery/Javascript, so please explain clearly.. Thanks!

-- EDIT -- And the jquery category switcher code below:

$(document).ready(function() { 

    $('ul#navfilter a').click(function() {

        $(this).css('outline','none');
        $('ul#navfilter .current').removeClass('current');
        $(this).parent().addClass('current');

        var filterVal = $(this).text().toLowerCase().replace(' ','-');      

        if(filterVal == 'alles') {
            $('.wrap .hidden').fadeTo('slow' ,0.8).removeClass('hidden');

        } else {


            $('.wrap .masonryWrap > div').each(function() {                                
                if(!$(this).hasClass(filterVal)) {      
                    $(this).fadeTo('slow' ,0.08).addClass('hidden');

                } else {
                    $(this).fadeTo('slow' ,0.8).removeClass('hidden');
                }
            });
        }
        return false;
    });
});

-- Edit -- The code for the navigation category filter with '0.99' for the 'recentlabel' transparency:

if(filterVal == 'alles') {
            $('.wrap .hidden').fadeTo('slow' ,0.8).removeClass('hidden');
            $('.recentlabel').fadeTo(400, 0.99);

        } else {


            $('.wrap .masonryWrap > div').each(function() {                                
                if(!$(this).hasClass(filterVal)) {      

    $(this).fadeTo('slow' ,0.08).addClass('hidden');  

    if (filterVal!='recent') 
      $(this).find('.recentlabel').fadeTo(400, 0);
    } else {  
      $(this).fadeTo('slow' ,0.8).removeClass('hidden');  
      $(this).find('.recentlabel').fadeTo(400, 0.99);  
    }
A: 

Try making duplicates of your selectors ".art" that apply to ".art .recentlabel" and call the selectors to fade explicitly.

Example

var $j = jQuery.noConflict();$j(document).ready(function(){    
    $j(".art").css({opacity: 0});   // Loaded at 0 opacity
    $j(".art").fadeTo(900, 0.8);    // Onload fade items to 80%
    $j(".art .recentlabel").css({opacity: 0});   // Loaded at 0 opacity
    $j(".art .recentlabel").fadeTo(900, 0.8);    // Onload fade items to 80%

    $j(".art").hover(function(){
  if(!$j(this).hasClass("hidden")){
    $j(".art .recentlabel").fadeTo("fast", 1.0); }  // Rollover at 100%
    },function(){
  if(!$j(this).hasClass("hidden")){
    $j(".art .recentlabel").fadeTo("fast", 0.8); }  // Rollout at 80%
    });
});
DeaconDesperado
Oké! that will get me a step further..But the transparency (shadow) of 'recentlabel' .png image is now doing strange stuff.. So now i'm thinking about using a non-transparent image (.jpg) (a square for example). Another thing is that the label doesn't fade out when switching category's. Can you please explain how to edit the code of the category switcher jquery i added in my original question above?I think i must add classes like 'recentlabel_art', 'recentlabel_graphicdesign' etc for this right?? Stuff like: 'if (this) == art, then fade ('.recentlabel_art') to 0.8 and rest labels to 0.08??
Just tested the original structure in IE7, and there the 'recentlabels' do fade along with the parent div's... :s
A: 

I would suggest hardcode (+/-) label hiding, i.e.:

if(!$(this).hasClass(filterVal)) {      
    $(this).fadeTo('slow' ,0.08).addClass('hidden');  
    if (filterVal!='recent')  
      $(this).find('.recentlabel').fadeTo('slow', 0.08);
    } else {  
      $(this).fadeTo('slow' ,0.8).removeClass('hidden');  
      $(this).find('.recentlabel').fadeTo('slow', 0.8);  
    }  

Nice design btw.

EDIT:

Your code:

$j(".art").hover(function(){
  if(!$j(this).hasClass("hidden")){
    $j(this).fadeTo("fast", 1.0); }  // Rollover at 100%
    },function(){
  if(!$j(this).hasClass("hidden")){
    $j(this).fadeTo("fast", 0.8); }  // Rollout at 80%
    });
});

Edited code (I set maximum alpha to 0.99, so I don't have to check for browser and eyes won't see difference):

$j(".art").hover(function(){
  if(!$j(this).hasClass("hidden")){
    $j(this).fadeTo("fast", 0.99); }  // Rollover at [100%] - A.K.: 99%
    },function(){
  if(!$j(this).hasClass("hidden")){
    $j(this).fadeTo("fast", 0.8); }  // Rollout at 80%
    });
});

Try this, it should work.

Adam Kiss
Thanks man!That works..Only thing now is that the transparency in the shadows of the label are weird in IE. But i think the only solution is to make a label without shading? Thank for the complement!
UTG Man :D Quick glance showed, that if you fadeTo 1 in IE, PNGs lose their alpha layer - solution - `if($.browser.msie)` - conditional test for ie - and if yes, don't fadeTo 1, but fadeTo highest alpha, where the transparency isn't wrong - i would try 0.99 ;)
Adam Kiss
Adam Kiss
well, you added that - I found it on YOUR website :D As for where to put that line - lookup in my answer for edit and gimme a sec ;)
Adam Kiss
Ok, now when page loads the labels look right.. But when selecting a category, all the labels look weird again. I thought changing the filter.js's '1.0' to '0.99' should work but it doesn't.. See my edit above.
Or do i have to change the '0' to '0.01'? -- EDIT -- No that won't help :)
Any suggestions?