🎈✨ 文字置換ゲーム ✨🎈
📜 1️⃣ 元の文章:
📝 ここに元の文章を入力してください...
✂️ 2️⃣ 削除する文字:
✍️ 削除したい文字を入力...
📤 3️⃣ 置換後の文字:
🖨️ 置換された文字がここに表示されます...
🎉
🎊
🎁
🎀
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>楽しい文字置換アプリ 🎉</title>
<style>
/* アニメーション */
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
40% {transform: translateY(-20px);}
60% {transform: translateY(-10px);}
}
@keyframes shake {
0% { transform: translate(1px, 1px) rotate(0deg); }
10% { transform: translate(-1px, -2px) rotate(-1deg); }
20% { transform: translate(-3px, 0px) rotate(1deg); }
30% { transform: translate(3px, 2px) rotate(0deg); }
40% { transform: translate(1px, -1px) rotate(1deg); }
50% { transform: translate(-1px, 2px) rotate(-1deg); }
60% { transform: translate(-3px, 1px) rotate(0deg); }
70% { transform: translate(3px, 1px) rotate(-1deg); }
80% { transform: translate(-1px, -1px) rotate(1deg); }
90% { transform: translate(1px, 2px) rotate(0deg); }
100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.click-effect:active {
animation: shake 0.5s;
}
.animate-button:hover {
animation: bounce 1s infinite;
}
</style>
</head>
<body>
<div style="width:400px; height:400px; border:2px solid #FFD700; border-radius:15px; padding:20px; box-sizing:border-box; background-color:#FFF8DC; position:relative; overflow:hidden;">
<div style="text-align:center; font-size:24px; margin-bottom:15px;">🎈✨ 文字置換ゲーム ✨🎈</div>
<div style="margin-bottom:15px;">
<div style="font-size:16px;">📜 <strong>1️⃣ 元の文章:</strong></div>
<div contenteditable="true" id="input1" style="border:2px dashed #FFA07A; border-radius:8px; padding:10px; min-height:60px; overflow:auto; font-size:14px; background-color:#FFF0F5; position:relative;">
📝 ここに元の文章を入力してください...
</div>
</div>
<div style="margin-bottom:15px;">
<div style="font-size:16px;">✂️ <strong>2️⃣ 削除する文字:</strong></div>
<div contenteditable="true" id="input2" style="border:2px dashed #98FB98; border-radius:8px; padding:10px; min-height:40px; overflow:auto; font-size:14px; background-color:#F0FFF0; position:relative;">
✍️ 削除したい文字を入力...
</div>
</div>
<div style="text-align:center; margin-bottom:15px;">
<input type="button" value="🔄 置換する!" id="replaceBtn" style="padding:10px 20px; font-size:16px; border:none; border-radius:10px; background-color:#FF69B4; color:white; cursor:pointer;" class="click-effect animate-button">
</div>
<div style="margin-bottom:15px;">
<div style="font-size:16px;">📤 <strong>3️⃣ 置換後の文字:</strong></div>
<div id="output" style="border:2px solid #87CEFA; border-radius:8px; padding:10px; min-height:40px; overflow:auto; font-size:14px; background-color:#E0FFFF; position:relative; cursor:pointer;">
🖨️ 置換された文字がここに表示されます...
</div>
</div>
<div style="text-align:center;">
<input type="button" value="📋 コピーする" id="copyBtn" style="padding:8px 16px; font-size:14px; border:none; border-radius:8px; background-color:#32CD32; color:white; cursor:pointer;" class="click-effect animate-button">
</div>
<!-- デコレーション絵文字 -->
<div style="position:absolute; top:5px; left:10px; font-size:30px;">🎉</div>
<div style="position:absolute; top:10px; right:15px; font-size:25px;">🎊</div>
<div style="position:absolute; bottom:10px; left:20px; font-size:25px;">🎁</div>
<div style="position:absolute; bottom:5px; right:10px; font-size:30px;">🎀</div>
</div>
<script>
document.getElementById('replaceBtn').addEventListener('click', function(){
const text1 = document.getElementById('input1').innerText;
const text2 = document.getElementById('input2').innerText;
if(text2.trim().length === 0){
alert('削除する文字を入力してください! 🎯');
return;
}
if(text1.includes(text2)){
const replacedText = text1.split(text2).join('');
document.getElementById('input1').innerText = replacedText;
document.getElementById('output').innerText = text2;
// 背景を伸ばす
const len = text2.length;
const container = document.querySelector('div[style*="width:400px"]');
container.style.backgroundSize = `${len * 5}px ${len * 5}px`;
} else {
alert('指定された文字が元の文章に含まれていません! ❌');
}
});
document.getElementById('copyBtn').addEventListener('click', function(){
const outputText = document.getElementById('output').innerText;
if(outputText.trim().length === 0 || outputText.includes('置換された文字')){
alert('コピーする文字がありません! 📭');
return;
}
navigator.clipboard.writeText(outputText).then(function() {
alert('コピーしました! 📋✨');
}, function(err) {
alert('コピーに失敗しました。 😓');
});
});
document.getElementById('output').addEventListener('click', function(){
this.style.backgroundColor = '#ADD8E6';
setTimeout(() => {
this.style.backgroundColor = '#E0FFFF';
}, 300);
});
</script>
</body>
</html>
```