initial commit

This commit is contained in:
2026-01-29 20:06:03 +08:00
commit 21cae2336c
14 changed files with 1530 additions and 0 deletions

680
css/style.css Normal file
View File

@@ -0,0 +1,680 @@
/* 全局样式重置 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', Arial, sans-serif;
background-color: #f1f1f1;
color: #333;
}
/* 主容器 */
.youtube-container {
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
}
/* 顶栏样式 */
.header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 16px;
height: 56px;
background-color: white;
border-bottom: 1px solid #e0e0e0;
position: sticky;
top: 0;
z-index: 100;
}
.header-left {
display: flex;
align-items: center;
}
.menu-btn {
background: none;
border: none;
font-size: 24px;
padding: 8px;
margin-right: 16px;
cursor: pointer;
color: #606060;
}
.youtube-logo img {
height: 20px;
}
.header-center {
display: flex;
align-items: center;
flex: 1;
max-width: 640px;
margin: 0 40px;
}
.search-container {
display: flex;
align-items: center;
width: 100%;
}
.search-input {
flex: 1;
height: 40px;
padding: 0 16px;
border: 1px solid #d3d3d3;
border-radius: 20px 0 0 20px;
font-size: 16px;
outline: none;
transition: all 0.3s ease;
}
.search-input:focus {
border-color: #1a73e8;
box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}
.search-btn {
height: 40px;
padding: 0 20px;
background-color: #f8f8f8;
border: 1px solid #d3d3d3;
border-left: none;
border-radius: 0 20px 20px 0;
cursor: pointer;
color: #606060;
}
.search-btn:hover {
background-color: #f0f0f0;
}
.voice-search-btn {
margin-left: 8px;
height: 40px;
width: 40px;
border-radius: 50%;
background-color: #f8f8f8;
border: none;
cursor: pointer;
color: #606060;
}
.voice-search-btn:hover {
background-color: #f0f0f0;
}
.header-right {
display: flex;
align-items: center;
}
.create-btn {
display: flex;
align-items: center;
background: none;
border: none;
padding: 8px 16px;
margin-right: 16px;
cursor: pointer;
color: #606060;
font-size: 14px;
}
.create-btn i {
margin-right: 4px;
font-size: 20px;
}
.notification-btn {
background: none;
border: none;
padding: 8px;
margin-right: 16px;
cursor: pointer;
color: #606060;
font-size: 20px;
}
.profile-btn {
background: none;
border: none;
padding: 8px;
cursor: pointer;
color: #606060;
font-size: 20px;
}
/* 主内容区 */
.main-content {
display: flex;
flex: 1;
overflow: hidden;
}
/* 侧边栏样式 */
.sidebar {
width: 240px;
background-color: white;
border-right: 1px solid #e0e0e0;
overflow-y: auto;
flex-shrink: 0;
}
.sidebar-nav {
padding: 12px 0;
}
.nav-section {
margin-bottom: 24px;
}
.nav-section-title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px 8px;
font-size: 14px;
font-weight: 500;
color: #606060;
text-transform: uppercase;
}
.nav-btn {
display: flex;
align-items: center;
width: 100%;
padding: 8px 24px;
background: none;
border: none;
text-align: left;
cursor: pointer;
font-size: 14px;
color: #333;
transition: background-color 0.2s ease;
}
.nav-btn:hover {
background-color: rgba(0, 0, 0, 0.05);
}
.nav-btn.active {
background-color: rgba(0, 0, 0, 0.1);
font-weight: 500;
}
.nav-btn i {
margin-right: 16px;
font-size: 20px;
width: 24px;
}
.subscriptions-list {
padding: 0 12px;
}
.subscription-item {
display: flex;
align-items: center;
padding: 8px 12px;
cursor: pointer;
border-radius: 8px;
transition: background-color 0.2s ease;
}
.subscription-item:hover {
background-color: rgba(0, 0, 0, 0.05);
}
.subscription-avatar {
width: 24px;
height: 24px;
border-radius: 50%;
margin-right: 12px;
background-color: #e0e0e0;
overflow: hidden;
}
.subscription-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.subscription-name {
font-size: 14px;
color: #333;
}
.sidebar-footer {
padding: 16px 24px;
font-size: 12px;
color: #909090;
border-top: 1px solid #e0e0e0;
}
/* 视频内容区 */
.video-content {
flex: 1;
overflow-y: auto;
padding: 24px;
background-color: #f9f9f9;
}
/* 板块按钮 */
.category-buttons {
display: flex;
gap: 12px;
margin-bottom: 24px;
flex-wrap: wrap;
}
.category-btn {
padding: 8px 16px;
background-color: white;
border: 1px solid #e0e0e0;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
}
.category-btn:hover {
background-color: #f1f1f1;
}
.category-btn.active {
background-color: #333;
color: white;
border-color: #333;
}
/* 视频网格 */
.video-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
gap: 24px;
margin-bottom: 48px;
}
/* 视频卡片 */
.video-card {
background-color: white;
border-radius: 12px;
transition: transform 0.2s ease, box-shadow 0.2s ease;
cursor: pointer;
position: static;
}
.video-thumbnail {
overflow: hidden;
border-radius: 12px 12px 0 0;
}
.video-menu {
position: relative;
z-index: 100;
}
.video-card:hover {
transform: translateY(-4px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.video-thumbnail {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 比例 */
background-color: #f1f1f1;
}
.video-thumbnail img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.video-duration {
position: absolute;
bottom: 8px;
right: 8px;
background-color: rgba(0, 0, 0, 0.8);
color: white;
font-size: 12px;
padding: 2px 6px;
border-radius: 4px;
}
.video-info {
display: flex;
padding: 12px;
}
.video-channel-avatar {
width: 36px;
height: 36px;
border-radius: 50%;
margin-right: 12px;
background-color: #e0e0e0;
}
.video-details {
flex: 1;
min-width: 0;
}
.video-title {
font-size: 14px;
font-weight: 500;
margin-bottom: 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.video-meta {
font-size: 12px;
color: #606060;
line-height: 1.4;
}
.video-channel {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 4px;
}
.video-stats {
display: flex;
gap: 8px;
}
.video-menu {
position: relative;
}
.menu-toggle {
background: none;
border: none;
padding: 8px;
cursor: pointer;
color: #606060;
font-size: 16px;
opacity: 0;
transition: opacity 0.2s ease;
}
.video-card:hover .menu-toggle {
opacity: 1;
}
.menu-dropdown {
position: absolute;
top: 100%;
right: 0;
background-color: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
padding: 8px 0;
min-width: 200px;
z-index: 1000;
display: none;
}
.menu-dropdown.show {
display: block;
}
.menu-item {
display: flex;
align-items: center;
padding: 8px 16px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.2s ease;
}
.menu-item:hover {
background-color: #f1f1f1;
}
.menu-item i {
margin-right: 12px;
font-size: 16px;
color: #606060;
}
/* Shorts 部分 */
.shorts-section {
margin-top: 48px;
}
.shorts-section h3 {
font-size: 20px;
font-weight: 500;
margin-bottom: 16px;
}
.shorts-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
gap: 16px;
}
/* Shorts 卡片 */
.shorts-card {
position: relative;
width: 100%;
padding-top: 177.78%; /* 9:16 比例 */
background-color: #f1f1f1;
border-radius: 12px;
overflow: hidden;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.shorts-card:hover {
transform: translateY(-4px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.shorts-thumbnail {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.shorts-thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
}
.shorts-info {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 12px;
background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
color: white;
}
.shorts-title {
font-size: 14px;
font-weight: 500;
margin-bottom: 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.shorts-stats {
font-size: 12px;
display: flex;
align-items: center;
gap: 8px;
}
.shorts-stats i {
margin-right: 4px;
}
/* 搜索结果弹窗 */
.search-results {
position: fixed;
top: 56px;
left: 0;
right: 0;
background-color: white;
border-bottom: 1px solid #e0e0e0;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
z-index: 99;
max-height: 80vh;
overflow-y: auto;
}
.search-results-content {
padding: 16px;
}
.search-result-item {
display: flex;
align-items: flex-start;
padding: 12px;
cursor: pointer;
border-radius: 8px;
transition: background-color 0.2s ease;
margin-bottom: 8px;
}
.search-result-item:hover {
background-color: #f1f1f1;
}
.search-result-thumbnail {
width: 120px;
height: 68px;
border-radius: 8px;
margin-right: 16px;
background-color: #f1f1f1;
flex-shrink: 0;
}
.search-result-thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 8px;
}
.search-result-details {
flex: 1;
min-width: 0;
}
.search-result-title {
font-size: 14px;
font-weight: 500;
margin-bottom: 4px;
line-height: 1.3;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
white-space: normal;
}
.search-result-channel {
font-size: 12px;
color: #606060;
margin-bottom: 2px;
}
.search-result-stats {
font-size: 12px;
color: #606060;
}
.highlight {
background-color: #fff3cd;
font-weight: 500;
}
/* 响应式设计 */
@media (max-width: 1200px) {
.video-grid {
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 20px;
}
}
@media (max-width: 992px) {
.sidebar {
width: 200px;
}
.video-grid {
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 16px;
}
}
@media (max-width: 768px) {
.sidebar {
display: none;
}
.header-center {
margin: 0 16px;
}
.create-btn span {
display: none;
}
.video-content {
padding: 16px;
}
.video-grid {
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 12px;
}
.shorts-grid {
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
gap: 12px;
}
}
@media (max-width: 576px) {
.header-center {
display: none;
}
.video-grid {
grid-template-columns: 1fr;
}
.shorts-grid {
grid-template-columns: repeat(4, 1fr);
}
}