我必须模拟滑块的功能,它有一些控件,如 next / prev按钮和切换全屏按钮。在全屏幕上,我必须在拉伸模式下显示滑块,我已经使用z-index完成了这个但是它不起作用,因为滑块的父级具有比其兄弟姐妹更低的z-index。你可以在这里看到实现
http://jsfiddle.net/HB7LU/22326/
<div id="slide" ng-class ='{fullscreen:isFullScreen}'
style="background : #FFEB3B;padding: 20px; margin:10px;" >
content of page {{currentPageNo}}
<div class="control">
<button ng-click="nextPage();">Next Page</button>
<button ng-click="isFullScreen = !isFullScreen;">Toggle Full Screen</button>
</div>
</div>
答案 0 :(得分:0)
您需要更好地调整z-index
css属性。问题是全屏元素的z-index
是相对于其父元素的,而它的父元素具有来自兄弟元素的较低值z-index
,所以这就是问题所在。请查看以下代码段:
var app = angular.module('myApp', []);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
app.controller('MyCtrl', function($scope) {
$scope.currentPageNo = 1;
$scope.nextPage = function() {
$scope.currentPageNo++;
}
})
.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 3; /*<------has the highest property*/
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app='myApp' ng-controller="MyCtrl">
<div style="background : #f00; margin:10px; position:relative; z-index : 1">
<!----------------------------------------------check above--^^^^^^^^^^^-->
Parent sibling Content
<br/>Parent sibling Content
<br/>
</div>
<div style="background : #4CAF50;margin:10px; position:relative; z-index :2">
<!-----------------------------------------------check above--^^^^^^^^^^^-->
Parent Content
<br/>Parent Content
<br/>
<div id="slide" ng-class='{fullscreen:isFullScreen}' style="background : #FFEB3B;padding: 20px; margin:10px;">
content of page {{currentPageNo}}
<div class="control">
<button ng-click="nextPage();">Next Page</button>
<button ng-click="isFullScreen = !isFullScreen;">Toggle Full Screen</button>
</div>
</div>
Parent Content
<br/>
</div>
</div>