Skip to content

Instantly share code, notes, and snippets.

@brian-griffin
Forked from harpalsingh/IE7_zindex_fix_for_parent
Created November 9, 2012 14:51
Show Gist options
  • Save brian-griffin/4046111 to your computer and use it in GitHub Desktop.
Save brian-griffin/4046111 to your computer and use it in GitHub Desktop.
We want to add a z-index of 1 to a container_div, but only if it contains a target_widget (we can't add z-index:1 to all container_div's)
<div class="container_div">
<div class="target_widget"></div>
</div>
<div class="container_div">
<div class="non_target"></div>
</div>
$('.target_widget').closest('.container_div').css('z-index','1');
@brian-griffin
Copy link
Author

We want to add a z-index of 1 to a container_div, but only if it contains a target_widget (we can't add z-index:1 to all container_div's).

We would prefer a css solution, but at present there is no known way of adding styling to a parent element from its child without using JavaScript/jQuery,

@brian-griffin
Copy link
Author

Added a jsfiddle example here
http://jsfiddle.net/NfYDt/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment