dialog标签实现原生Popover弹出框效果代码

代码语言:html

所属分类:弹出层

代码描述:dialog标签实现原生Popover弹出框效果代码

代码标签: dialog 标签 原生 Popover 弹出框

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #1849AB;
  --primary-hover: #357abd;
  --focus-color: #4a90e2;
  --text-color: #333;
  --background-light: #f5f5f5;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: arial;
}

.button-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popover-trigger {
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s ease;
}

.popover-trigger:hover {
  background-color: var(--primary-hover);
}

.popover-trigger:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

dialog[popover] {
  padding: 1.5rem;
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 28rem;
  width: 90%;
  margin: auto;
  background: white;
  animation: slide-in 0.3s ease;
}

.close-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background-color: var(--background-light);
  color: var(--text-color);
  border: 2px solid transparent;
  border-radius: 50%;
  font-size: 1.125rem;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.close-button:hover {
  background-color: .........完整代码请登录后点击上方下载按钮下载查看

网友评论0