顶级SVG上的iframe z-index

时间:2018-12-04 00:21:56

标签: html css svg iframe

我有以下HTML:

      <div class="media-canvas">
             <div class="slide-wrap">
                    <iframe src="//www.myslidesexample.com" width="800" height="450" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe>
             </div>
      </div>

以及以下CSS:

.media-canvas {
    position: relative;

    svg {
        position: relative; /* To display the canvas above the illustration */
        width: 100%;
        height: auto;
    }

    &::before {
        content: '';
        position: absolute;
        width: 320px;
        height: 230px;
        bottom: -76px;
        left: calc(50% - 160px);
        background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTMwIiBoZWlnaHQ9IjM4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4gICAgPGRlZnM+ICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjguNjg1JSIgeTE9IjIzLjczMyUiIHgyPSI4NS44MDglIiB5Mj0iODIuODM3JSIgaWQ9Im1lZGlhLWlsbHVzdHJhdGlvbi1hIj4gICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGIiBzdG9wLW9wYWNpdHk9Ii40OCIgb2Zmc2V0PSIwJSIvPiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkYiIHN0b3Atb3BhY2l0eT0iMCIgb2Zmc2V0PSIxMDAlIi8+ICAgICAgICA8L2xpbmVhckdyYWRpZW50PiAgICAgICAgPGxpbmVhckdyYWRpZW50IHgxPSItNS44ODElIiB5MT0iNDIuNzQzJSIgeDI9IjkyLjgyNyUiIHkyPSIwJSIgaWQ9Im1lZGlhLWlsbHVzdHJhdGlvbi1iIj4gICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRjk0MjVGIiBvZmZzZXQ9IjAlIi8+ICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0Y5N0M1OCIgc3RvcC1vc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41ODIuODEtMS44Mzd6Ii8+ICAgICAgICA8cGF0aCBmaWxsPSIjNzQ4N0EzIiBkPSJNMzE1LjMxNCAzMTVsMi44OTkgMS4zMzQuNzg3IDIuODIzLS45MjYgMi42ODgtMi43NiAxLjE1NS0yLjYtMS4zMS0xLjcxNC0yLjUzMyAxLjI5NS0yLjk0ek0zNDYuMzE0IDMyMWwyLjg5OSAxLjMzNC43ODcgMi44MjMtLjkyNiAyLjY4OC0yLjc2IDEuMTU1LTIuNi0xLjMxLTEuNzE0LTIuNTMzIDEuMjk1LTIuOTR6Ii8+ICAgICAgICA8cGF0aCBmaWxsPSIjNTU2QjhCIiBkPSJNMzczLjY5NiAzNjRsMS44MTIuODMzLjQ5MiAxLjc2NS0uNTc5IDEuNjgtMS43MjUuNzIyLTEuNjI0LS44Mi0xLjA3Mi0xLjU4Mi44MS0xLjgzN3pNNDA5LjY5NiAzMjZsMS44MTIuODMzLjQ5MiAxLjc2NS0uNTc5IDEuNjgtMS43MjUuNzIyLTEuNjI0LS44Mi0xLjA3Mi0xLjU4Mi44MS0xLjgzN3pNMzc5LjY5NiAzMjZsMS44MTIuODMzLjQ5MiAxLjc2NS0uNTc5IDEuNjgtMS43MjUuNzIyLTEuNjI0LS44Mi0xLjA3Mi0xLjU4Mi44MS0xLjgzN3pNNDE5LjYxOCAzNDZsMS4wODcuNS4yOTUgMS4wNTktLjM0NyAxLjAwOC0xLjAzNS40MzMtLjk3NS0uNDkyLS42NDMtLjk1LjQ4Ni0xLjEwMXoiLz4gICAgPC9nPjwvc3ZnPg==);
        background-repeat: no-repeat;
        background-size: 320px 230px;
    }
}

.media-control {
    position: absolute;
    top: calc(50% - 24px);
    left: calc(50% - 24px);
    cursor: pointer;

    svg {
        width: 48px;
        height: 48px;
        overflow: visible;
    }
}

@include media( '>medium' ) {

    .media {

        .section-inner {
            padding-bottom: 144px;
        }

        .section-paragraph {
            padding-left: 72px;
            padding-right: 72px;
            margin-bottom: 80px;
        }
    }

    .media-canvas {

        &::before {
            width: 530px;
            height: 380px;
            bottom: -128px;
            left: calc(50% - 275px);
            background-size: 530px 380px;
        }
    }

    .media-control {
        top: calc(50% - 48px);
        left: calc(50% - 48px);

        svg {
            width: 96px;
            height: 96px;
        }
    }
}

SVG似乎绘制在上述CSS的&::before区域内。

发生的情况的屏幕截图: https://lizzieenterprise.box.com/s/w2hmysalew3joxf8uzk6rc7cbn3fzo82

我希望iframe幻灯片放到SVG设计之上。我该怎么办?

1 个答案:

答案 0 :(得分:0)

在CSS内,将iframe的z-index设置为比野人更大的值。确保为两个项目都定义值,例如

media {
  z-index:99;
}
svg {
  z-index:1;
}

默认情况下,野蛮人的z-index可能低于iframe的默认z-index,或者可能存在其他问题。无论哪种方式,都应通过为两个项目分配z-index来解决。