-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
layout: ../../../layouts/Layout.astro | ||
pubDate: "2025-01-16" | ||
updatedDate: "2025-01-16" | ||
title: "dialog要素の背面のスクロールを無効化する" | ||
author: ダーシノ | ||
description: "<dialog>要素(モーダルダイアログ)を表示するときに注意したいのが、元の要素のスクロール。 overscroll-behaviorで対処できなくはないが、カーソルが外れるとダイアログの裏側要素がスクロールされてしまう。" | ||
tags: ["CSS"] | ||
--- | ||
|
||
import Header from '../../../components/Header.astro' | ||
|
||
<Header {...frontmatter} /> | ||
|
||
`<dialog>`要素(モーダルダイアログ)を表示するときに注意したいのが、元の要素のスクロール。 | ||
[overscroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior)で対処できなくはないが、カーソルが外れるとダイアログの裏側要素がスクロールされてしまう。 | ||
|
||
そんなときのTIPS。 | ||
```css | ||
/* open状態のdiaog要素を持つ要素のスクロールを無効化する。 */ | ||
:has(dialog[open]) { | ||
overflow: hidden; | ||
} | ||
``` |