Qiita Conference 2025

ミノ駆動 (@MinoDriven)

プロフェッショナルとしての成長──「問題の深掘り」が導く真のスキルアップ

3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HTMLとCSSのみでダイアログ表示

Posted at

できること

JavaScriptなしで、HTMLとCSSのみを使用してダイアログ表示を行います。

ダイアログ機能.gif

動画のようにボタンをクリックすると、ダイアログが表示されます。
読んで欲しい文章を表示させることができます。

※ダイアログとは「ダイアログボックス」のことをいいます。何かを入力させたりメッセージを確認させるために、操作の過程で一時的に開かれる小さい画面のことです。

HTML

index.html
 <dialog id="dialog" class="dialog_style" >
                        「ダイアログの中身の文章(任意)」
   <button class="form__btn" onclick="document.getElementById('dialog').close();">
                       「ダイアログの中身にあるボタンの文章(任意)」
   </button>
 </dialog>
 
<button class="form__btn" onclick="document.getElementById('dialog').show();">
                    「クリックするとダイアログが表示されるボタンの文章(任意)」
                    </button>

CSS

styles.css

.dialog_style{ 
margin-left: 300px;
width: 1000px;
height: 500px;
border: 5px solid #b84c00;
border-radius: 10px;
}

.form__btn{
 〜省略〜
}

.form__btn:hover {
〜省略〜
}

CSSはお好みで記述してください。

以上です。

3
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?