浏览器原生Popover API 弹出层完整用法示例代码

代码语言:html

所属分类:弹出层

代码描述:浏览器原生Popover API 弹出层完整用法示例代码

代码标签: 浏览器 原生 Popover API 弹出层 完整 用法 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Popover API 完整示例</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: system-ui, -apple-system, sans-serif;
            padding: 40px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 40px;
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
        }

        h1 {
            color: #333;
            margin-bottom: 10px;
        }

        .subtitle {
            color: #666;
            margin-bottom: 40px;
            font-size: 14px;
        }

        .demo-section {
            margin-bottom: 40px;
            padding: 30px;
            background: #f8f9fa;
            border-radius: 12px;
            border-left: 4px solid #667eea;
        }

        .demo-section h2 {
            color: #667eea;
            margin-bottom: 15px;
            font-size: 20px;
        }

        .demo-section p {
            color: #666;
            margin-bottom: 20px;
            line-height: 1.6;
        }

        /* 按钮样式 */
        button {
            padding: 12px 24px;
            margin: 5px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            background: #667eea;
            color: white;
        }

        button:hover {
            background: #5568d3;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

        button:active {
            transform: translateY(0);
        }

        button.secondary {
            background: #48bb78;
        }

        button.secondary:hover {
            background: #38a169;
        }

        button.danger {
            background: #f56565;
        }

        button.danger:hover {
            background: #e53e3e;
        }

        /* Popover 基础样式 */
        [popover] {
            border: none;
            border-radius: 12px;
            padding: 0;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            background: white;
            overflow: hidden;
        }

        /* Popover 背景遮罩 */
        [popover]::backdrop {
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(4px);
        }

        /* 简单 Popover */
        #simple-popover {
            padding: 24px;
            max-width: 300px;
        }

        #simple-popover h3 {
            color: #667eea;
            margin-bottom: 12px;
        }

        /* 表单 Popover */
        #form-popover {
            width: 400px;
            max-width: 90vw;
        }

        .popover-header {
            padding: 20px 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            display:.........完整代码请登录后点击上方下载按钮下载查看

网友评论0