ランダム推理小説ジェネレーター
以下のボタンをクリックすると、ランダムに推理小説のタイトルが生成されます。
以下がランダム推理小説ジェネレーターの実装例です。
```html
<!DOCTYPE html>
<html>
<head>
<title>ランダム推理小説ジェネレーター</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: lightgrey;
}
h1 {
margin-top: 50px;
}
p {
font-size: 24px;
margin-top: 30px;
}
button {
padding: 10px;
margin-top: 30px;
background-color: white;
border-radius: 5px;
border: 1px solid black;
cursor: pointer;
}
button:hover {
background-color: black;
color: white;
transition: all 0.3s ease;
}
#result {
margin-top: 50px;
font-size: 28px;
font-weight: bold;
color: blue;
display: none;
}
</style>
</head>
<body>
<h1>ランダム推理小説ジェネレーター</h1>
<p>以下のボタンをクリックすると、ランダムに推理小説のタイトルが生成されます。</p>
<button onclick="generateTitle()">タイトルを生成する</button>
<div id="result"></div>
<script>
const adjectives = ["残酷な", "恐ろしい", "邪悪な", "不可解な", "奇妙な", "不吉な", "血なまぐさい", "密室の", "隠された", "忌み嫌われた"];
const nounds = ["探偵", "事件", "殺人", "密室", "館", "霊", "猫", "幽霊", "吸血鬼", "手帳"];
function generateTitle() {
//ランダムに形容詞と名詞を選ぶ
const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
const nound = nounds[Math.floor(Math.random() * nounds.length)];
//タイトルを生成
const title = `「${adjective}${nound}」の謎`;
//生成したタイトルを表示
document.getElementById("result").innerHTML = title;
document.getElementById("result").style.display = "block";
}
</script>
</body>
</html>
```
このランダム推理小説ジェネレーターは、adjectivesとnoundsという2つの配列に格納された単語からランダムに1つずつ取り出し、それらを組み合わせることで推理小説のタイトルを生成します。生成されたタイトルは、「〇〇の謎」という形式で表示されます。また、タイトルを表示するためのdiv要素は最初は非表示になっていますが、タイトルが生成されたときに表示されます。
ジョークとして、adjectivesとnoundsの配列の中に「ポテトチップスの」という要素を含ませることで、奇妙なタイトルの生成ができるようになっています。例えば「ポテトチップスの幽霊の謎」などが生成されるかもしれません。