浏览器原生Popover API弹出层用法示例代码
代码语言:html
所属分类:弹出层
代码描述:浏览器原生Popover API弹出层用法示例代码
代码标签: 浏览器 原生 Popover API 弹出层 用法 示例 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<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;
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
body {
padding: 40px;
line-height: 1.6;
color: #1f2937;
background-color: #f9fafb;
}
.container {
max-width: 1200px;
margin: 0 auto;
gap: 40px;
display: flex;
flex-direction: column;
}
.section {
background: white;
padding: 24px;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
h2 {
margin-bottom: 20px;
color: #111827;
font-size: 20px;
font-weight: 600;
border-bottom: 1px solid #e5e7eb;
padding-bottom: 12px;
}
.demo-group {
display: flex;
flex-wrap: wrap;
gap: 16px;
margin-bottom: 24px;
}
/* 通用按钮样式 */
.btn {
padding: 10px 20px;
border: none;
border-radius: 6px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s;
display: inline-flex;
align-items: center;
gap: 8px;
}
.btn-primary {
background: #3b82f6;
color: white;
}
.btn-primary:hover {
background: #2563eb;
}
.btn-danger {
background: #dc2626;
color: white;
}
.btn-danger:hover {
background: #b91c1c;
}
.btn-secondary {
background: #f3f4f6;
color: #374151;
}
.btn-secondary:hover {
background: #e5e7eb;
}
.icon-btn {
width: 40px;
height: 40px;
border-radius: 50%;
background: #f3f4f6;
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: #1f2937;
transition: background 0.15s;
}
.icon-btn:hover {
background: #e5e7eb;
}
/* 1. 基础示例样式 */
.basic-popover {
padding: 20px;
border-radius: 8px;
background: white;
border: 1px solid #e5e7eb;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
min-width: 280px;
}
/* 2. 用户头像下拉菜单样式 */
.main-nav {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.nav-trigger {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
background: transparent;
border: 1px solid #e5e7eb;
border-radius: 6px;
cursor: pointer;
transition: background 0.15s;
}
.nav-trigger:hover {
background: #f9faf.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0