Here's a simplified YouTube-like website in a single HTML file with embedded CSS and JavaScript:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTubeClone</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
/* Header Styles */
.header {
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
padding: 15px;
background-color: white;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
.logo {
display: flex;
align-items: center;
}
.logo img {
width: 100px;
margin-left: 10px;
}
.search-bar {
display: flex;
align-items: center;
width: 40%;
}
.search-input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 20px 0 0 20px;
}
.search-btn {
padding: 10px 20px;
background: #f8f8f8;
border: 1px solid #ddd;
border-radius: 0 20px 20px 0;
cursor: pointer;
}
.user-icons {
display: flex;
align-items: center;
gap: 20px;
}
/* Main Content Styles */
.main {
display: flex;
margin-top: 60px;
}
/* Sidebar Styles */
.sidebar {
width: 240px;
background-color: white;
position: fixed;
top: 60px;
left: 0;
bottom: 0;
padding: 10px;
overflow-y: auto;
}
.sidebar-item {
display: flex;
align-items: center;
padding: 10px 20px;
cursor: pointer;
}
.sidebar-item:hover {
background-color: #f2f2f2;
border-radius: 10px;
}
.sidebar-item span {
margin-left: 15px;
}
/* Video Grid Styles */
.videos-container {
margin-left: 240px;
padding: 20px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
.video-card {
cursor: pointer;
}
.thumbnail {
width: 100%;
height: 150px;
background-color: #f2f2f2;
border-radius: 10px;
}
.video-info {
display: flex;
margin-top: 10px;
}
.channel-icon {
width: 36px;
height: 36px;
border-radius: 50%;
background-color: #ddd;
margin-right: 10px;
}
.video-details h3 {
font-size: 14px;
margin-bottom: 5px;
}
.video-details p {
font-size: 12px;
color: #666;
}
</style>
</head>
<body>
<div class="header">
<div class="logo">
<i class="material-icons">menu</i>
<img src="https://www.youtube.com/img/desktop/yt_1200.png" alt="YouTube Logo">
</div>
<div class="search-bar">
<input type="text" class="search-input" placeholder="Search">
<button class="search-btn">
<i class="material-icons">search</i>
</button>
</div>
<div class="user-icons">
<i class="material-icons">video_call</i>
<i class="material-icons">apps</i>
<i class="material-icons">notifications</i>
<i class="material-icons">account_circle</i>
</div>
</div>
<div class="main">
<div class="sidebar">
<div class="sidebar-item">
<i class="material-icons">home</i>
<span>Home</span>
</div>
<div class="sidebar-item">
<i class="material-icons">explore</i>
<span>Explore</span>
</div>
<div class="sidebar-item">
<i class="material-icons">subscriptions</i>
<span>Subscriptions</span>
</div>
<div class="sidebar-item">
<i class="material-icons">video_library</i>
<span>Library</span>
</div>
<div class="sidebar-item">
<i class="material-icons">history</i>
<span>History</span>
</div>
</div>
<div class="videos-container" id="videosContainer">
<!-- Videos will be dynamically added here -->
</div>
</div>
<script>
// Sample video data
const videos = [
{
title: "Amazing Video Title 1",
channel: "Channel Name 1",
views: "1M views",
timestamp: "3 days ago"
},
{
title: "Amazing Video Title 2",
channel: "Channel Name 2",
views: "500K views",
timestamp: "1 week ago"
},
{
title: "Amazing Video Title 3",
channel: "Channel Name 3",
views: "2M views",
timestamp: "2 weeks ago"
},
{
title: "Amazing Video Title 4",
channel: "Channel Name 4",
views: "750K views",
timestamp: "1 month ago"
},
{
title: "Amazing Video Title 5",
channel: "Channel Name 5",
views: "1.5M views",
timestamp: "2 months ago"
},
{
title: "Amazing Video Title 6",
channel: "Channel Name 6",
views: "3M views",
timestamp: "3 months ago"
}
];
// Function to create video cards
function createVideoCards() {
const videosContainer = document.getElementById('videosContainer');
videos.forEach(video => {
const videoCard = document.createElement('div');
videoCard.className = 'video-card';
videoCard.innerHTML = `
<div class="thumbnail"></div>
<div class="video-info">
<div class="channel-icon"></div>
<div class="video-details">
<h3>${video.title}</h3>
<p>${video.channel}</p>
<p>${video.views} • ${video.timestamp}</p>
</div>
</div>
`;
videosContainer.appendChild(videoCard);
});
}
// Initialize the page
createVideoCards();
</script>
</body>
</html>
This code creates a simplified version of YouTube with the following features:
-
A fixed header with:
- Menu icon and YouTube logo
- Search bar
- User action icons
-
A sidebar with:
- Navigation menu items
- Material icons for each menu item
-
A main content area with:
- Grid layout for videos
- Video cards with thumbnails
- Channel icons
- Video information
-
Responsive design that adjusts the video grid based on screen size
-
Basic hover effects and styling
To use this code:
- Save it as an HTML file
- Make sure you have an internet connection (for Material Icons)
- Open it in a web browser
Note that this is a simplified version and doesn't include all YouTube features. Some things that could be added to make it more complete:
- Video playback functionality
- Comments section
- More detailed sidebar sections
- User authentication
- Real video thumbnails and channel icons
- More interactive features
- Dark mode toggle
- More responsive design elements
The styling can also be further improved to match YouTube's exact look and feel, but this provides a good foundation for a YouTube-like interface.