Create a clone of HackerNews
- User
Create a clone of HackerNews
Assistant
Create a clone of HackerNews
Here's a modern, responsive clone of Hacker News with HTML, CSS, and basic structure. This single-file solution includes a clean design with upvote functionality placeholders and responsive layout:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hacker News Clone</title>
<style>
:root {
--hn-orange: #ff6600;
--hn-bg: #f6f6ef;
}
body {
font-family: 'Segoe UI', system-ui, sans-serif;
margin: 0;
padding: 0;
background: var(--hn-bg);
color: #333;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
header {
background: var(--hn-orange);
padding: 10px 0;
position: sticky;
top: 0;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.header-content {
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
color: white;
font-weight: bold;
font-size: 1.5em;
text-decoration: none;
}
nav a {
color: white;
text-decoration: none;
margin-left: 20px;
}
.post-form {
background: white;
padding: 20px;
border-radius: 8px;
margin: 20px 0;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
input, textarea {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ddd;
border-radius: 4px;
}
button {
background: var(--hn-orange);
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
transition: opacity 0.2s;
}
button:hover {
opacity: 0.8;
}
.post {
background: white;
padding: 15px;
margin: 10px 0;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.post-header {
display: flex;
align-items: center;
gap: 10px;
}
.points {
color: var(--hn-orange);
font-weight: bold;
}
.post-title {
font-size: 1.1em;
color: #000;
text-decoration: none;
}
.post-meta {
color: #666;
font-size: 0.9em;
margin: 8px 0;
}
.comment-count {
color: #666;
font-style: italic;
}
@media (max-width: 600px) {
.container {
padding: 10px;
}
.header-content {
flex-direction: column;
}
}
</style>
</head>
<body>
<header>
<div class="container header-content">
<a href="#" class="logo">Hacker News</a>
<nav>
<a href="#">new</a>
<a href="#">past</a>
<a href="#">comments</a>
<a href="#">ask</a>
<a href="#">submit</a>
</nav>
</div>
</header>
<div class="container">
<div class="post-form">
<h2>Add a new post</h2>
<form id="postForm">
<input type="text" placeholder="Title" required>
<input type="url" placeholder="URL" required>
<button type="submit">Submit</button>
</form>
</div>
<div id="posts">
<!-- Sample post -->
<div class="post">
<div class="post-header">
<button>▲</button>
<span class="points">42</span>
<a href="#" class="post-title">New Programming Language Features in 2024</a>
</div>
<div class="post-meta">
Submitted 2h ago by <a href="#">user123</a>
<span class="comment-count">| 15 comments</span>
</div>
</div>
</div>
</div>
<script>
// Add JavaScript functionality here
// (Post submission, voting, comments, etc.)
</script>
</body>
</html>
This clone includes:
For a fully functional clone, you'd need to add JavaScript to handle:
Would you like me to add any specific functionality to the JavaScript portion?