- This topic is empty.
-
AuthorPosts
-
May 8, 2012 at 11:45 am #37983
BryGuy
MemberHello All,
My site Born Squishy works great in firefox and was starting to look okay in Explorer 9 with the exception of stacked elements via z-index.
I tried using jquery-1.3.2.min.js code posted in “Fixing IE z-index” shown below:
$(function() {
var zIndexNumber = 1000;
// Put your target element(s) in the selector below!
$("div").each(function() {
$(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});
});I posted the script in the head and entered in some elements in one area to test it shown here:
I did a quick test and nothing seemed to change, although I have no idea if I incorporated the .js correctly.
What am I missing?
May 8, 2012 at 1:03 pm #102522May 8, 2012 at 1:42 pm #102524BryGuy
MemberThanks Senff, I forgot to link my site and I was a bit vague. I edited my original post. Let me know if more information is required.
May 8, 2012 at 3:47 pm #102531TheDoc
MemberIE has a huge problem with commas in JS that don’t have a meaning.
You’ve got a few console errors firing up, even in Chrome.
I’m a little confused with the following code:
$(".welcome-mat #welcome-box #grid_postdate .grid_15 #text-4 #textwidget .primary_content_wrap").each(function() {
$(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});“.welcome-mat #welcome-box #grid_postdate .grid_15 #text-4 #textwidget .primary_content_wrap”
That line is a single selector, there are no commas. The ‘each’ function is looking for “.welcome-mat #welcome-box #grid_postdate .grid_15 #text-4 #textwidget .primary_content_wrap”, which it won’t be able to find.
May 8, 2012 at 6:53 pm #102543BryGuy
MemberDoc – I managed to eliminate 1 console error and I’m addressing the 2nd one now.
To tell you the truth I have absolutely no idea when it comes to javascript. I now understand that I should’ve put a comma after each element….. ie: #welcome-box, #grid_postdate,….. etc.
After I made that change I tried running my site again in Explorer and it still didn’t make any difference.
I have no idea if I’m even approaching this problem correctly. If there’s a better way of having z-index display properly in explorer I’d love to implement it.
May 8, 2012 at 9:27 pm #102550TheDoc
MemberI’m not really sure what you’re using the z-index for?
May 8, 2012 at 10:02 pm #102552BryGuy
Memberif you view this page in firefox/Chrome or Safari you’ll see a blue tab to the left of the welcome box. When you hover over the tab it slides out to reveal a welcome mat. The mat is layed via z-index so that it is wedged between the welcome box and the layer below it.
I also managed to get rid of the console errors.
May 9, 2012 at 2:33 pm #102602TheDoc
MemberAh.
Instead of applying the z-index via jQuery, why not just assign them all via CSS? They ever need to dynamically change.
May 9, 2012 at 6:37 pm #102619BryGuy
MemberWell that’s the problem. The z-index is defined via CSS and it’s not working in Explorer. The whole jQuery idea came about when I started to research the problem I was having and found a link here on css-tricks (in my original post).
I’m trying to figure out what I have to change in my CSS or elsewhere to get it to appear correctly in IE.
May 9, 2012 at 7:01 pm #102620TheDoc
MemberIt’s tough because everything you’ve got is a bit messy.
Here is an example of z-index working in IE8 as well as all other modern browsers.
May 9, 2012 at 9:32 pm #102627BryGuy
MemberThanks for the feedback Doc. I didn’t take offense to the “a bit messy” comment, but I was wondering if you could elaborate a bit. This is the first site I’ve ever worked on, so I’m not surprised it’s considered messy. Once I know what to clean up, I can address the z-index again.
May 9, 2012 at 9:34 pm #102630JoshWhite
MemberI’m just on my phone now so I can’t take a look until later but what I’ve seen with ie is that it always goes the parent element and ignores everything that’s within it unit that parent is defined.
So for example if you had several divs within a header with a z index it would only begin reacting properly once the header itself joined the z index party. I don’t know if that’s helpful right away but it could give you a starting place to make some adjustments and see what happens.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.