z索引无法在Chrome浏览器中使用?

时间:2015-12-11 08:16:24

标签: javascript css html5

z-index无法在Chrome浏览器中运行,它会弹出容器后面。如果我更改菜单的z-index,则“链接按钮”可以单击。

$(function() {
      $('.ui-323 ul.ui-nav > li').tooltip();
    });

    $(document).ready(function() {

      $(".ui-323 ul.ui-nav > li > a").click(function(e) {
        e.preventDefault();
        if (!($(this).parents(".ui-323").hasClass("active"))) {
          //$(this).parents(".ui-323").addClass("active");		//Add Class Active
        } else {
          $(this).parents(".ui-323").removeClass("active"); //Remove Class Active
        }
      });

      $(".ui-323 ul.ui-nav > li > a").mouseleave(function(e) {
        e.preventDefault();
        $(this).parents(".ui-323").addClass("active");
      });
    });
body {
	color: #666666;
	font-size: 13px;
	line-height: 23px;
	background: #fff;
	font-family: 'Open Sans', sans-serif;
	-webkit-font-smoothing: antialiased;
}
.tab-content{z-index: 999;
position: relative;}
.bg_ctr{
      height: 200px;
      position: relative;
    width: 65%;
    float: left;
    margin-top: 40px;
    margin-left: 133px;
    background-color: white;
    border: 1px solid #C7C7C7;
  
}
h1,
h2,
h3,
h4,
h5,
h6 {
	color: #666;
	font-family: 'Open Sans', sans-serif;
	font-weight: 600;
	margin: 0px 0px;
	padding: 0px;
}
h1 {
	font-size: 30px;
	line-height: 45px;
}
h2 {
	font-size: 25px;
	line-height: 40px;
}
h3 {
	font-size: 22px;
	line-height: 37px;
}
h4 {
	font-size: 18px;
	line-height: 33px;
}
h5 {
	font-size: 15px;
	line-height: 30px;
}
h6 {
	font-size: 13px;
	line-height: 28px;
}
p {
	margin: 2px 0px;
	padding: 0px;
	margin-bottom:5px;
	line-height:28px;
}
a{
	text-decoration: none;
	color: #777;
}
a:hover,a:active,a:focus {
	outline: 0;
	text-decoration: none;
	color: #999;
}
hr {
	margin: 10px 0px;
	padding: 0px;
	border-top: 0px;
	border-bottom: 1px solid #eee;
}
:focus {
	outline:none;
}
::-moz-focus-inner {
	border:0;
}
/* Text color classes */
.white {
  color: #ffffff !important;
}
.grey {
  color: #eeeeee !important;
}
.black {
  color: #555555 !important;
}
.red {
  color: #f75353 !important;
}
.green {
  color: #51d466 !important;
}
.lblue {
  color: #32c8de !important;
}
.blue {
  color: #609cec !important;
}
.orange {
  color: #f78153 !important;
}
.yellow {
  color: #fcd419 !important;
}
.purple {
  color: #cb79e6 !important;
}
.rose {
  color: #ff61e7 !important;
}
.brown {
  color: #d08166 !important;
}
/* Background color classes */
.bg-white {
  background-color: #ffffff !important;
}
.bg-grey {
  background-color: #eeeeee !important;
}
.bg-black {
  background-color: #555555 !important;
}
.bg-red {
  background-color: #f75353 !important;
}
.bg-green {
  background-color: #51d466 !important;
}
.bg-lblue {
  background-color: #32c8de !important;
}
.bg-blue {
  background-color: #609cec !important;
}
.bg-orange {
  background-color: #f78153 !important;
}
.bg-yellow {
  background-color: #fcd419 !important;
}
.bg-purple {
  background-color: #cb79e6 !important;
}
.bg-rose {
  background-color: #ff61e7 !important;
}
.bg-brown {
  background-color: #d08166 !important;
}
/* Border color classes */
.br-white {
  border: 1px solid #ffffff !important;
}
.br-grey {
  border: 1px solid #eeeeee;
}
.br-black {
  border: 1px solid #555555;
}
.br-red {
  border: 1px solid #f75353;
}
.br-green {
  border: 1px solid #51d466;
}
.br-lblue {
  border: 1px solid #32c8de;
}
.br-blue {
  border: 1px solid #609cec;
}
.br-orange {
  border: 1px solid #f78153;
}
.br-yellow {
  border: 1px solid #fcd419;
}
.br-purple {
  border: 1px solid #cb79e6;
}
.br-rose {
  border: 1px solid #ff61e7;
}
.br-brown {
  border: 1px solid #d08166;
}
/* Button classes */
.btn {
	border-radius: 2px;
	position: relative;
}
.btn.btn-no-border {
	border: 0px !important;
}
/* Button colors */
.btn.btn-white {
	background: #ffffff;
	color: #666666;
	border: 1px solid #dddddd;
}
.btn.btn-white:hover,
.btn.btn-white:focus,
.btn.btn-white.active,
.btn.btn-white:active {
	background: #f7f7f7;
	color: #666666;
}
.btn.btn-grey {
	background: #eeeeee;
	color: #666666;
	border: 1px solid #d5d5d5;
}
.btn.btn-grey:hover,
.btn.btn-grey:focus,
.btn.btn-grey.active,
.btn.btn-grey:active {
	background: #d5d5d5;
	color: #999;
}
.btn.btn-black {
	color: #ffffff;
	background: #666666;
	border: 1px solid #4d4d4d;
}
.btn.btn-black:hover,
.btn.btn-black:focus,
.btn.btn-black.active,
.btn.btn-black:active {
	background: #4d4d4d;
	color: #ffffff;
}
.btn.btn-red {
	color: #ffffff;
	background: #ed5441;
	border: 1px solid #e52d16;
}
.btn.btn-red:hover,
.btn.btn-red:focus,
.btn.btn-red.active,
.btn.btn-red:active {
	color: #ffffff;
	background: #e52d16;
}
.btn.btn-green {
	color: #ffffff;
	background: #51d466;
	border: 1px solid #30c247;
}
.btn.btn-green:hover,
.btn.btn-green:focus,
.btn.btn-green.active,
.btn.btn-green:active {
	background: #30c247;
	color: #ffffff;
}
.btn.btn-lblue {
	color: #ffffff;
	background: #32c8de;
	border: 1px solid #1faabe;
}
.btn.btn-lblue:hover,
.btn.btn-lblue:focus,
.btn.btn-lblue.active,
.btn.btn-lblue:active {
	background: #1faabe;
	color: #ffffff;
}
.btn.btn-blue {
	color: #ffffff;
	background: #609cec;
	border: 1px solid #3280e7;
}
.btn.btn-blue:hover,
.btn.btn-blue:focus,
.btn.btn-blue.active,
.btn.btn-blue:active {
	background: #3280e7;
	color: #ffffff;
}
.btn.btn-orange {
	color: #ffffff;
	background: #f8a841;
	border: 1px solid #f69110;
}
.btn.btn-orange:hover,
.btn.btn-orange:focus,
.btn.btn-orange.active,
.btn.btn-orange:active {
	background: #f69110;
	color: #ffffff;
}
.btn.btn-yellow {
	background: #fcd419;
	color: #ffffff;
	border: 1px solid #dfb803;
}
.btn.btn-yellow:hover,
.btn.btn-yellow:focus,
.btn.btn-yellow.active,
.btn.btn-yellow:active {
	background: #dfb803;
	color: #ffffff;
}
.btn.btn-purple {
	background: #cb79e6;
	color: #ffffff;
	border: 1px solid #ba4ede;
}
.btn.btn-purple:hover,
.btn.btn-purple:focus,
.btn.btn-purple.active,
.btn.btn-purple:active {
	background: #ba4ede;
	color: #ffffff;
}
.btn.btn-rose {
	background: #ff61e7;
	color: #ffffff;
	border: 1px solid #ff2edf;
}
.btn.btn-rose:hover,
.btn.btn-rose:focus,
.btn.btn-rose.active,
.btn.btn-rose:active {
	background: #ff2edf;
	color: #ffffff;
}
.btn.btn-brown {
	background: #d08166;
	color: #ffffff;
	border: 1px solid #c4613f;
}
.btn.btn-brown:hover,
.btn.btn-brown:focus,
.btn.btn-brown.active,
.btn.btn-brown:active {
	background: #c4613f;
	color: #ffffff;
}
/* Label */
.label {
	border-radius: 2px;
	font-weight: normal;
	padding: 3px 7px;
	font-size: 12px;
	line-height: 18px;
}
/* Label sizes */
.label.label-xs {
	font-size: 10px;
	padding: 1px 5px;
	line-height: 12px;
}
.label.label-sm {
	font-size: 11px;
	padding: 2px 6px;
	line-height: 15px;
}
.label.label-lg {
	font-size: 13px;
	padding: 5px 9px;
	line-height: 23px;
}
/* Label colors */
.label.label-white{
	color: #666666 !important;
	background: #f7f7f7;
}
.label.label-grey {
	color: #666666 !important;
	background: #eeeeee;
}
.label.label-black {
	color: #ffffff;
	background: #666666;
}
.label.label-red {
	color: #ffffff;
	background: #ed5441;
}
.label.label-green {
	color: #ffffff;
	background: #51d466;
}
.label.label-lblue {
	color: #ffffff;
	background: #32c8de;
}
.label.label-blue {
	color: #ffffff;
	background: #609cec;
}
.label.label-orange {
	color: #ffffff;
	background: #f8a841;
}
.label.label-yellow {
	background: #fcd419;
	color: #ffffff;
}
.label.label-purple {
	background: #cb79e6;
	color: #ffffff;
}
.label.label-rose {
	background: #ff61e7;
	color: #ffffff;
}
.label.label-brown {
	background: #d08166;
	color: #ffffff;
}
/* Badges */
.badge {
	min-width: 10px;
	padding: 3px 7px !important;
	font-size: 12px;
	line-height: 12px;
	font-weight: normal;
	display: inline-block;
	color: #fff;
	border-radius: 10px;
}
.badge.badge-white {
	color: #666666;
	background: #ffffff;
}
.badge.badge-grey {
	color: #a2a2a2;
	background: #eeeeee;
}
.badge.badge-black {
	color: #ffffff;
	background: #666666;
}
.badge.badge-red {
	color: #ffffff;
	background: #ed5441;
}
.badge.badge-green {
	color: #ffffff;
	background: #51d466;
}
.badge.badge-lblue {
	color: #ffffff;
	background: #32c8de;
}
.badge.badge-blue {
	color: #ffffff;
	background: #609cec;
}
.badge.badge-orange {
	color: #ffffff;
	background: #f8a841;
}
.badge.badge-yellow {
	color: #ffffff;
	background: #fcd419;
}
.badge.badge-purple {
	color: #ffffff;
	background: #cb79e6;
}
.badge.badge-rose {
	color: #ffffff;
	background: #ff61e7;
}
.badge.badge-brown {
	color: #ffffff;
	background: #d08166;
}
.btn .badge {
	position: absolute;
	top: -13px;
	right: -8px;
}
/* Social Media */
.facebook {	background: #3280e7; }
.facebook:hover { background: #134fa0; }
.twitter { background: #32c8de;}
.twitter:hover {	background: #188392;}
.google-plus {background: #f96f4a;}
.google-plus:hover {	background: #eb6440;}
.linkedin  {	background: #729fda;}
.linkedin:hover {background: #3069b6;}
.pinterest {	background: #ed5441;}
.pinterest:hover { background: #b72411;}
.dropbox {background: #32c8de;}
.dropbox:hover {	background: #188392;}
.bitcoin {background: #f8a841;}
.bitcoin:hover {	background: #cc7607;}
.foursquare {background: #22bed4;}
.foursquare:hover {background: #146f7c;}
.flickr { background: #ff61e7;}
.flickr:hover {	background: #fa00d4;}
.github {background: #666666;}
.github:hover {	background: #333333;}
.instagram {	background: #d6917a;}
.instagram:hover {background: #b35637;}
.skype {background: #32c8de;}
.skype:hover {background: #188392;}
.tumblr {background: #84a1c8;}
.tumblr:hover {background: #476d9f;}
.vimeo {background: #32c8de;}
.vimeo:hover {background: #188392;}
.dribbble{background: #ff2edf;}
.dribbble:hover {background: #c700a9;}
.youtube {background: #ed5441;}
.youtube:hover {	background: #b72411;}

/* General CSS */
/* Body */
body{
	background: #f4f8fd;
}
/* UI - X */
.ui-323{
	max-width: 310px;
	margin: 40px auto;
	padding:0px 20px;
	overflow: hidden;
}
/* Nav Tabs */
.ui-323 ul.ui-nav{
	float: left;
	padding: 0px;
	list-style-type: none;
	margin-bottom: 0px;
}
/* Listing */
.ui-323 ul.ui-nav > li{
	position: relative;
}
.ui-323 ul.ui-nav > li.active::before{
	content: "\f0d9";
	font-family: "FontAwesome" ;
	position: absolute;
	top: 20px;
	right: -2px;
	font-size: 30px;
	color: #fff;
	opacity: 1;
	-webkit-transition: all 1s;
    -moz-transition: all 1s;
    -o-transition: all 1s;
    transition: all 1s;
}
.ui-323.active ul.ui-nav > li.active::before{
	opacity: 0;
}
.ui-323 ul.ui-nav > li > a{
	display: block;
	font-size: 20px;
	text-align: center;
	width: 60px;
	height: 60px;
	line-height: 60px;
	color: #fff;
	border-bottom: 1px solid rgba(255,255,255,0.2);
}
.ui-323 ul.ui-nav > li:last-child > a{
	border-bottom: 0px;
}
/* Tab Content */
.ui-323 .tab-content{
	margin-left: 60px;
	max-width: 320px;
	height: 100%;
	background: #fff;
	-webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -o-transition: all 0.5s;
	-ms-transition: all 0.5s;
    transition: all 0.5s;
    z-index: 99;
position: relative;
}
.ui-323.active .tab-content{
	max-width: 0px;
}
/* Tab Pane */
.ui-323 .tab-content .tab-pane{
	opacity: 1;
	border: 1px solid #ddd;
	border-left: 0px;
	-webkit-transition: all 2s;
    -moz-transition: all 2s;
    -o-transition: all 2s;
	-ms-transition: all 2s;
	transition: all 2s;
}
.ui-323.active .tab-content .tab-pane{
	opacity: 0;
	-webkit-transition: all 0.2s;
    -moz-transition: all 0.2s;
    -o-transition: all 0.2s;
	-ms-transition: all 0.2s;
    transition: all 0.2s;
}
/* Main Heading */
.ui-323 .tab-content .tab-pane h3{
	font-size: 14px;
	line-height: 25px;
	text-transform: uppercase;
	margin: 18px 25px 8px;
	color:#888;
}
@media(max-width: 274px){
	.ui-323 .tab-content .tab-pane h3{
		font-size: 12px;
		margin: 18px 8px 8px;
	}
}
.ui-323 .tab-content .tab-pane h3 > i{
	font-size: 13px;
	line-height: 23px;
	margin-right:8px;
}
/* Headings */
.ui-323 .tab-content .tab-pane ul li{
	font-size: 14px;
	line-height: 24px;
	margin: 0px;
	padding: 8px 2px;
	font-weight:400;
}
@media(max-width: 274px){
	.ui-323 .tab-content .tab-pane ul li{
		font-size: 12px;
		padding: 8px;
	}
}
.ui-323 .tab-content .tab-pane  ul li > a{
	display: block;
	width: 100%;
}
.ui-323 .tab-content .tab-pane  ul li > a::before{
	content: "\f101";
	font-family: "FontAwesome";
	font-weight: 400;
	margin-right: 6px;
	font-size: 14px;
	line-height: 24px;
	color: #bbb;
}
.ui-323  .tab-content .tab-pane  ul li > a > span{
	display: block;
	float: right;
	margin-top: 4px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://ashobiz.asia/boot-extended15/ui/js/placeholder.js"></script>
<script src="http://ashobiz.asia/boot-extended15/ui/js/bootstrap.min.js"></script>
<div class="ui-323 active " style="position: fixed; width: 100%;">
  <!-- Nav tabs -->
  <ul class="ui-nav bg-lblue">
    <!-- Bars -->
    <li>
      <a href="#" class="ui-bar">
        <i class="fa fa-home"></i>
      </a>
    </li>
    <!-- Tabs -->
    <li class="active" data-toggle="tooltip" data-placement="right" title="User">
      <a href="#one" class="ui-user" data-toggle="tab">
        <!-- Icon -->
        <i class="fa fa-user"></i>
      </a>
    </li>
    <!-- Tabs -->
    <li data-toggle="tooltip" data-placement="right" title="Doctor">
      <a href="#two" class="ui-doctor" data-toggle="tab">
        <!-- Icon -->
        <i class="fa fa-user-md"></i>
      </a>
    </li>
    <!-- Tabs -->
    <li data-toggle="tooltip" data-placement="right" title="Patient">
      <a href="#three" class="ui-patient" data-toggle="tab">
        <!-- Icon -->
        <i class="fa fa-heartbeat"></i>
      </a>
    </li>
    <!-- Tabs -->
    <li data-toggle="tooltip" data-placement="right" title="Settings">
      <a href="#four" class="ui-settings" data-toggle="tab">
        <!-- Icon -->
        <i class="fa fa-cog"></i>
      </a>
    </li>
    <!-- Tabs -->
    <li data-toggle="tooltip" data-placement="right" title="Import File">
      <a href="#five" class="ui-import" data-toggle="tab">
        <!-- Icon -->
        <i class="fa fa-database"></i>
      </a>
    </li>
  </ul>
  <!-- Tab Content -->
  <div class="tab-content">
    <!-- Tab Pane -->
    <div class="tab-pane fade in active clearfix" id="one">
      <!-- Main Heading -->
      <h3><i class="fa fa-user lblue"></i>User</h3>
      <ul class="list-unstyled">
        <li><a href="../UI/CreateNewUser.aspx" class="active">Create New User</a>
        </li>
        <li><a href="../UI/EditUserDetails.aspx">Edit Existing User</a>
        </li>

      </ul>
    </div>
    <!-- Tab Pane -->
    <div class="tab-pane fade clearfix" id="two">
      <!-- Main Heading -->
      <h3><i class="fa fa-user-md lblue"></i>Doctor</h3>
      <ul class="list-unstyled">
        <li><a href="#" class="active">Doctor Link1</a>
        </li>
        <li><a href="#">Doctor Link2</a>
        </li>
        <li><a href="#">Doctor Link2</a>
        </li>

      </ul>
    </div>
    <!-- Tab Pane -->
    <div class="tab-pane fade clearfix" id="three">
      <!-- Main Heading -->
      <h3><i class="fa fa-heartbeat lblue"></i>Patient</h3>
      <ul class="list-unstyled">
        <li><a href="#" class="active">Patient Link1</a>
        </li>
        <li><a href="#">Patient Link2</a>
        </li>
        <li><a href="#">Patient Link3</a>
        </li>
        <li><a href="#">Patient Link4</a>
        </li>
        <li><a href="#">Patient Link5</a>
        </li>
        <li><a href="#">Patient Link6</a>
        </li>
        <li><a href="#">Patient Link7</a>
        </li>
      </ul>
    </div>
    <!-- Tab Pane -->
    <div class="tab-pane fade clearfix" id="four">
      <!-- Main Heading -->
      <h3><i class="fa fa-cog lblue"></i>Settings</h3>
      <ul class="list-unstyled">
        <li><a href="#" class="active">Settings Link1</a>
        </li>
        <li><a href="#">Settings Link2</a>
        </li>
        <li><a href="#">Settings Link3</a>
        </li>
        <li><a href="#">Settings Link4</a>
        </li>
        <li><a href="#">Settings Link5</a>
        </li>
        <li><a href="#">Settings Link6</a>
        </li>
      </ul>
    </div>
    <!-- Tab Pane -->
    <div class="tab-pane fade clearfix" id="five">
      <!-- Main Heading -->
      <h3><i class="fa fa-database lblue"></i>Import File</h3>
      <ul class="list-unstyled">
        <li><a href="../UI/ImportPatients.aspx" class="active">Import Patients</a>
        </li>

      </ul>
    </div>
  </div>
</div>

<div class="bg_ctr">
  <a href="">click</a>

</div>
</div>

以下是fiddle

4 个答案:

答案 0 :(得分:0)

试试这个:

.tab-content{
    z-index: 999;
    position: absolute; /*position has to be absolute*/
}

答案 1 :(得分:0)

您的父容器.ui-323的位置为:fixed和z-index:auto(默认情况下) &安培; child .tab-content有z-index:999;哪个不行。

你应该给.ui-323 z-index:-1; &安培; child z-index:1;使它工作。

Stacking Context Ref

答案 2 :(得分:0)

只需将z-index提交给.ui-323即可。

因为.tab-content的父容器position:fixed需要比z-index更高的bg_ctr类才能显示在顶部。

.ui-323{
    max-width: 310px;
    margin: 40px auto;
    padding:0px 20px;
    overflow: hidden;
  z-index:1; // Here given z-index
}

<强> Working Fiddle

修改

要解决链接可点击问题,请添加以下css:

.ui-323.active{
    z-index:-1;
}

<强> Updated Fiddle

答案 3 :(得分:0)

您只需在正确的元素上放置正确的位置和z-index。

我假设您希望左子菜单(.ui-323)超过其他元素:

.ui-323 {
  z-index: 10;
}