Skip to content

Commit 02ab96d

Browse files
committed
passes z-index8 non-positioned element with opactiy < 1
The MDN article Understanding_z_index/Stacking_and_float is wrong about this
1 parent 65746bd commit 02ab96d

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Parse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ _html2canvas.Parse = function (images, options) {
331331
stack.zIndex = newContext = h2czContext(zIndex);
332332
newContext.isPositioned = isPositioned;
333333
newContext.isFloated = isFloated;
334+
newContext.opacity = opacity;
334335

335336
if (zIndex !== 'auto' || opacity < 1) {
336337
newContext.ownStacking = true;

src/Renderer.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ _html2canvas.Renderer = function(parseQueue, options){
4848

4949
// positioned after static
5050
context[zi].forEach(function(v) {
51-
if (v.node.zIndex.isFloated) {
52-
floated.push(v);
53-
} else if (v.node.zIndex.isPositioned) {
51+
if (v.node.zIndex.isPositioned || v.node.zIndex.opacity < 1) {
52+
// http://www.w3.org/TR/css3-color/#transparency
53+
// non-positioned element with opactiy < 1 should be stacked as if it were a positioned element with ‘z-index: 0’ and ‘opacity: 1’.
5454
positioned.push(v);
55+
} else if (v.node.zIndex.isFloated) {
56+
floated.push(v);
5557
} else {
5658
nonPositioned.push(v);
5759
}

0 commit comments

Comments
 (0)