您可以通过添加以下CSS样式来解决白色边框问题:

.popup-content iframe {
    border: none;
}

然后在<iframe>标签上添加class="iframe-full":

<iframe class="iframe-full" src="手机/index.html" width="100%" height="100%"></iframe>

最后,在<style>标签中添加以下样式:

.iframe-full {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

这样就能让<iframe>填充整个弹窗,并去掉边框。完整代码如下:

<!DOCTYPE html>
<html>
<head>
    <style>
        /* 弹窗样式 */
        .popup {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 9999;
        }
        
        .popup-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
        }
        
        /* 文字点击样式 */
        .clickable-text {
            cursor: pointer;
            text-decoration: underline;
        }
        
        .popup-content iframe {
            border: none;
        }
        
        .iframe-full {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <p>点击下面的文字弹出弹窗:</p>
    <p class="clickable-text" onclick="showPopup()">点击弹窗</p>
    
    <div id="popup" class="popup">
        <div class="popup-content">
            <h2>这是一个弹窗</h2>
            <p>这是弹窗的内容。</p>
            <iframe class="iframe-full" src="手机/index.html" width="100%" height="100%"></iframe>
            <button onclick="hidePopup()">关闭弹窗</button>
        </div>
    </div>
    
    <script>
        function showPopup() {
            document.getElementById("popup").style.display = "block";
        }
        
        function hidePopup() {
            document.getElementById("popup").style.display = "none";
        }
    </script>
</body>
</html>

这样应该能够解决边框问题并让<iframe>占满整个页面。

!DOCTYPE htmlhtmlhead style 弹窗样式 popup display none; position fixed; top 0; left 0; width 100; height 100;

原文地址: https://www.cveoy.top/t/topic/i7pN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录