Skip to content

Commit b1f948b

Browse files
committed
Fix z-index stacking with fixed position
1 parent 24d9a22 commit b1f948b

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

dist/html2canvas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ function renderableNode(node) {
20472047

20482048
function isPositionedForStacking(container) {
20492049
var position = container.css("position");
2050-
var zIndex = (position === "absolute" || position === "relative") ? container.css("zIndex") : "auto";
2050+
var zIndex = (["absolute", "relative", "fixed"].indexOf(position) !== -1) ? container.css("zIndex") : "auto";
20512051
return zIndex !== "auto";
20522052
}
20532053

dist/html2canvas.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodeparser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ function renderableNode(node) {
617617

618618
function isPositionedForStacking(container) {
619619
var position = container.css("position");
620-
var zIndex = (position === "absolute" || position === "relative") ? container.css("zIndex") : "auto";
620+
var zIndex = (["absolute", "relative", "fixed"].indexOf(position) !== -1) ? container.css("zIndex") : "auto";
621621
return zIndex !== "auto";
622622
}
623623

tests/cases/zindex/z-index17.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title>z-index17</title>
6+
<style>
7+
.z {
8+
background: darkolivegreen;
9+
position: fixed;
10+
right: 0;
11+
left: 0;
12+
height: 100px;
13+
z-index: 10;
14+
top: 0;
15+
}
16+
body {
17+
background: violet;
18+
}
19+
</style>
20+
<script type="text/javascript" src="../../test.js"></script>
21+
</head>
22+
<body>
23+
<div class="z">fixed z-index 10</div>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)