示例工程 31-modals-dropdowns

31-modals-dropdowns/demo-02-dialog/style.css

css · 1.4 KB

运行:dialog 模态

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

body {
  margin: 0;
  padding: 32px;
  background: #f8fafc;
  color: #0f172a;
  font-family: system-ui, sans-serif;
  line-height: 1.7;
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn.danger {
  border-color: #dc2626;
  background: #dc2626;
  color: #ffffff;
}

.btn:focus-visible,
.close:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

body:has(dialog[open]) { overflow: hidden; }

.dialog {
  width: min(92vw, 440px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 24px 64px rgb(15 23 42 / 28%);
}

.dialog::backdrop {
  background: rgb(15 23 42 / 55%);
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.head h2 { margin: 0; font-size: 17px; }

.close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
}

.body {
  margin: 0;
  padding: 16px 20px;
  color: #64748b;
  font-size: 14px;
}

.foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.foot form { display: contents; }