万年カレンダーの表示HTML

万年カレンダーの表示HTML

デスクトップなどに置いて使える万年カレンダーを生成します。 生成されたサンプルは次のURLにも置いてあります。 mori1-hakua.tokyo/test/GMOcalendar.html

0
0
183
10

投稿日時:

  • プロンプト実行例
  • プロンプトを見る
万年カレンダーの表示HTML

デスクトップなどで使える万年カレンダーです。 生成されたサンプルは、次のURLにも置いてあります。 https://mori1-hakua.tokyo/test/GMOcalendar.html

開始曜日

土曜色

日曜色

本日背景

万年カレンダーの表示HTML

は、要件に従って作成されたHTML、CSS、JavaScriptを含む完全なコードです。

html
1<!DOCTYPE html>
2<html lang="ja">
3<head>
4  <meta charset="UTF-8">
5  <style>
6    body {
7      font-family: Arial, sans-serif;
8    }
9    table {
10      width: 100%;
11      border-collapse: collapse;
12      margin-top: 20px;
13    }
14    th, td {
15      border: 1px solid #000;
16      padding: 10px;
17      text-align: center;
18    }
19    th {
20      background-color: #f2f2f2;
21    }
22    td.today {
23      font-weight: bold;
24      background-color: yellow;
25      border: 2px solid #000;
26    }
27    td.sunday {
28      color: red;
29      font-weight: bold;
30    }
31    td.saturday {
32      color: blue;
33      font-weight: bold;
34    }
35  </style>
36</head>
37<body>
38
39<div>
40  <button onclick="prevMonth()">&#171; 前月</button>
41  <h1 id="currentMonth"></h1>
42  <button onclick="nextMonth()">次月 &#187;</button>
43</div>
44
45<table id="calendar">
46  <tr>
47    <th></th>
48    <th></th>
49    <th></th>
50    <th></th>
51    <th></th>
52    <th></th>
53    <th></th>
54  </tr>
55</table>
56
57<script>
58  let currentDate = new Date();
59  let currentYear = currentDate.getFullYear();
60  let currentMonth = currentDate.getMonth();
61
62  function generateCalendar(year, month) {
63    let firstDay = new Date(year, month, 1);
64    let lastDay = new Date(year, month + 1, 0);
65
66    document.getElementById('calendar').innerHTML = '';
67
68    // Add current month and year to heading
69    document.getElementById('currentMonth').innerText = `${year}${month + 1}`;
70
71    // Add day names to the table
72    let dayNames = ['日', '月', '火', '水', '木', '金', '土'];
73    let headerRow = document.getElementById('calendar').insertRow();
74    for (let i = 0; i < 7; i++) {
75      let cell = headerRow.insertCell();
76      cell.appendChild(document.createTextNode(dayNames[i]));
77    }
78
79    // Add dates to the table
80    let date = new Date(firstDay);
81    let calendarBody = document.getElementById('calendar');
82    let row = calendarBody.insertRow();
83    for (let i = 0; i < firstDay.getDay(); i++) {
84      let cell = row.insertCell();
85      cell.appendChild(document.createTextNode(new Date(year, month, 0).getDate() - (firstDay.getDay() - 1) + i));
86      cell.style.color = '#ccc';
87    }
88
89    for (let i = 1; i <= lastDay.getDate(); i++) {
90      date.setDate(i);
91      if (date.getDay() === 0) {
92        row = calendarBody.insertRow();
93      }
94      let cell = row.insertCell();
95      cell.appendChild(document.createTextNode(i));
96      if (year === currentDate.getFullYear() && month === currentDate.getMonth() && i === currentDate.getDate()) {
97        cell.classList.add('today');
98      }
99      if (date.getDay() === 0) {
100        cell.classList.add('sunday');
101      } else if (date.getDay() === 6) {
102        cell.classList.add('saturday');
103      }
104    }
105
106    for (let i = lastDay.getDay() + 1; i < 7; i++) {
107      let cell = row.insertCell();
108      cell.appendChild(document.createTextNode(i - lastDay.getDay()));
109      cell.style.color = '#ccc';
110    }
111  }
112
113  function prevMonth() {
114    currentMonth -= 1;
115    if (currentMonth < 0) {
116      currentYear -= 1;
117      currentMonth = 11;
118    }
119    generateCalendar(currentYear, currentMonth);
120  }
121
122  function nextMonth() {
123    currentMonth += 1;
124    if (currentMonth > 11) {
125      currentYear += 1;
126      currentMonth = 0;
127    }
128    generateCalendar(currentYear, currentMonth);
129  }
130
131  generateCalendar(currentYear, currentMonth);
132</script>
133
134</body>
135</html>

このコードは、指定された要件に従って万年カレンダーを作成します。年月表示の上には前月と次月の移動ボタンがあり、日曜日と土曜日の日付に色が付けられ、本日の日付には特別なスタイルが適用されます。JavaScript部分では、前月と次月のボタンがクリックされた際に、カレンダーが更新されるようになっています。

コメント 0

他のプロンプトもチェック

  • メール作成

    推奨モデル - GPT 4o
    一度にいくつも重なると、整理が大変なので、そんな時に一般的な整理のフレームワークを提供します。医療・健康・金融など、専門的な相談には答えられません。それは人間の専門家の領域だから。雑に話すと整理してくれる道具、くらいに受け止めて下さると嬉しいです。
    0
    0
    1
    56
  • GPTs

    SNS投稿

    このGPTは、あなたの日本語文章を高度に解析し、その文体スタイルをそっくりそのまま再現するためのツールです。文末表現、語彙、文構造、リズム、敬語の使い分け、助詞の使用方法など、あらゆる日本語特有の要素を詳細に解析し、あなたの個性を生かした文体スタイルをリスト化します。 使い方: ・2,000文字以上の文章を入力し、文体スタイルを解析します。2000文字以上のテキストを送信してください。 ChatGPT4をご利用の方はファイルから文章データを送ることができます。 ・結果として、あなたの日本語の文章の特徴が詳細にリスト化され、再現可能な文体スタイルが提供されます。 ポイント: ・日本語特有の文末表現や敬語の使い分けまで、細部にわたり解析することで、より正確で個性的な文体スタイルを再現できます。 ・自分の書き方をより深く理解し、意識的に自分らしい文章を書くことができるようになります。 注意点: ・表示される文体解析結果で文章を作っても、ChatGPT特有の日本語表現は表示されることがあります。その点は、手動でリストを修正してご利用ください。例:「これにより」「これによって」等 このGPTを使って、あなたの文章スタイルをリスト化させ、ライティングに活用してみてください。 #日本語 #文体解析 #文章スタイル #文章改善 #AIツール #ライティングアシスタント
    5
    1
    90
    330
  • 文案作成

    推奨モデル - GPT 4o
    👇最新作はこちら👇 https://oshiete.ai/profiles/user_55332610834961408 指定した「キーワード」だけでSEOに強い、長文のブログ記事を書いていくれます。 ブログは「大見出し」「中見だし」「小見出し」「まとめ」など、セクション形式にまとめてくれ、タイトルも自動で選定してくれます。  #ブログ #副業 #記事 #記事作成 #執筆 #ライター #SEO
  • ロールプレイ

    ようこそ!このセッションでは、キャバクラで女性との会話を自然かつ魅力的に展開するための戦略とテクニック、さらに魅力的なメールの書き方までを学びます。上品な会話の始め方から感情の共有、適切な質問の仕方、聞き手としてのスキル、そして会話をスマートに締めくくる方法まで、会話の達人になるための秘訣をご紹介します。彼女について教えていただければ、より適切なアドバイスを提供できます!このチャットがお役に立ったと感じたら、ぜひ他の方々にも推薦してください!
    2
    0
    8
    190