ํญ์๋ ๐ง๐ง๐ง๐ง๐ง๐ง ( ์์ง ๋ชป ๋ณด์ ๊ฒ ๊ฐ๊ธธ๋ ์ํฐ๋ก ์์ ์ ๋์ด๋ดค์ต๋๋ค. ์.. ์ฃ์กํฉ๋๋ค. )
์ค์ 2025-06-27 19:02โข์กฐํ 84โข๋๊ธ 7โข์ต
์๋ ๊ฑธ๋ก ๋ง๋ค์ด์ฃผ์ค ์ ์๋์
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>๊ฒ์ํ ์ฌ์ดํธ</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: white;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
header h1 {
margin: 0;
font-size: 20px;
}
#addPostBtn {
font-size: 24px;
cursor: pointer;
background: none;
border: none;
color: white;
}
.board-container {
display: flex;
flex-wrap: wrap;
padding: 10px;
}
.section {
flex: 1 1 300px;
border: 1px solid #ccc;
margin: 10px;
padding: 10px;
}
.section h2 {
margin-top: 0;
}
.post {
border-top: 1px solid #ddd;
padding: 5px 0;
}
/* Modal ์คํ์ผ */
.modal {
display: none;
position: fixed;
z-index: 10;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 10% auto;
padding: 20px;
border: 1px solid #888;
width: 300px;
}
.modal-content select, .modal-content input, .modal-content textarea {
width: 100%;
margin: 10px 0;
padding: 5px;
}
.modal-content button {
padding: 8px 16px;
margin-top: 10px;
background-color: #333;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<header>
<h1>๋์ ๊ฒ์ํ</h1>
<button id="addPostBtn">๏ผ</button>
</header>
<div class="board-container">
<div class="section" id="free">
<h2>์์ ๊ฒ์ํ</h2>
<div class="posts"></div>
</div>
<div class="section" id="share">
<h2>๋๋ ๊ฒ์ํ</h2>
<div class="posts"></div>
</div>
<div class="section" id="talk">
<h2>์ํต ๊ฒ์ํ</h2>
<div class="posts"></div>
</div>
<div class="section" id="promo">
<h2>ํ๋ณด ๊ฒ์ํ</h2>
<div class="posts"></div>
</div>
<div class="section" id="etc">
<h2>๊ธฐํ ๊ฒ์ํ</h2>
<div class="posts"></div>
</div>
</div>
<!-- ๊ฒ์๊ธ ์ถ๊ฐ ๋ชจ๋ฌ -->
<div id="postModal" class="modal">
<div class="modal-content">
<h3>๊ฒ์๋ฌผ ์ถ๊ฐ</h3>
<select id="sectionSelect">
<option value="">์น์
์ ํ</option>
<option value="free">์์ ๊ฒ์ํ</option>
<option value="share">๋๋ ๊ฒ์ํ</option>
<option value="talk">์ํต ๊ฒ์ํ</option>
<option value="promo">ํ๋ณด ๊ฒ์ํ</option>
<option value="etc">๊ธฐํ ๊ฒ์ํ</option>
</select>
<input type="text" id="postTitle" placeholder="์ ๋ชฉ ์
๋ ฅ">
<textarea id="postContent" placeholder="๋ด์ฉ ์
๋ ฅ" rows="4"></textarea>
<button id="submitPost">์๋ฃ</button>
</div>
</div>
<script>
const addPostBtn = document.getElementById('addPostBtn');
const modal = document.getElementById('postModal');
const submitPost = document.getElementById('submitPost');
addPostBtn.onclick = () => {
modal.style.display = 'block';
};
// ๋ชจ๋ฌ ์ธ ํด๋ฆญ ์ ๋ซ๊ธฐ
window.onclick = function(event) {
if (event.target === modal) {
modal.style.display = "none";
}
};
submitPost.onclick = () => {
const section = document.getElementById('sectionSelect').value;
const title = document.getElementById('postTitle').value;
const content = document.getElementById('postContent').value;
if (!section) {
alert('์น์
์ ์ ํํด ์ฃผ์ธ์.');
return;
}
const postHTML = `
<div class="post">
<strong>${title}</strong><br>
<p>${content}</p>
</div>
`;
document.querySelector(`#${section} .posts`).innerHTML += postHTML;
// ์ด๊ธฐํ ๋ฐ ๋ชจ๋ฌ ๋ซ๊ธฐ
document.getElementById('sectionSelect').value = '';
document.getElementById('postTitle').value = '';
document.getElementById('postContent').value = '';
modal.style.display = 'none';
};
</script>
</body>
</html>