以下は、シンプルなSNSアプリの例です。
```html
<!DOCTYPE html>
<html>
<head>
<title>My SNS App</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
h1 {
text-align: center;
color: #333;
}
.post-form {
background-color: #fff;
padding: 20px;
max-width: 500px;
margin: 0 auto;
}
.post-form textarea {
width: 100%;
height: 100px;
resize: vertical;
}
.post-form button {
margin-top: 10px;
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
float: right;
}
.post-list {
background-color: #fff;
padding: 20px;
max-width: 600px;
margin: 20px auto;
}
.post {
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #ddd;
overflow-wrap: break-word;
}
.post span {
font-weight: bold;
color: #333;
}
.post p {
margin-top: 5px;
}
</style>
</head>
<body>
<h1>Welcome to My SNS App!</h1>
<div class="post-form">
<textarea id="postText" placeholder="What's on your mind?"></textarea>
<button onclick="addPost()">Post</button>
</div>
<div class="post-list" id="postList">
<!-- 記事が追加される部分 -->
</div>
<script>
// 記事を管理する配列
var posts = [];
// 記事を追加する関数
function addPost() {
var postText = document.getElementById("postText").value;
var post = {
text: postText,
date: new Date()
};
posts.push(post);
renderPosts();
document.getElementById("postText").value = "";
}
// 記事を表示する関数
function renderPosts() {
var postList = document.getElementById("postList");
postList.innerHTML = "";
posts.forEach(function(post) {
var postElement = document.createElement("div");
postElement.classList.add("post");
postElement.innerHTML = `<span>${post.date.toLocaleString()}</span><p>${post.text}</p>`;
postList.appendChild(postElement);
});
}
// 初期表示
renderPosts();
</script>
</body>
</html>
```
この例では、シンプルなSNSアプリのUIを実装しています。ユーザーはテキストボックスにメッセージを入力し、投稿ボタンをクリックすることでメッセージを投稿することができます。投稿されたメッセージは下に表示されます。
このアプリにはセキュリティ上の脆弱性はありませんが、テキストのエスケープ処理など、実際のアプリケーションで必要なセキュリティ対策を追加することが重要です。
ジョークを取り入れる場合、例えば投稿ボタンに「Send a message into the void」というキャプションを追加することができます。