Skip to content

Commit 2347539

Browse files
author
Buttwood
committed
feat:mobile video
1 parent 0f4a5e9 commit 2347539

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

www/css/style.css

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ a {
404404
left: 0;
405405
right: 0;
406406
bottom: 0;
407+
transition: background-color 0.3s ease;
407408
}
408409

409410
#background_video {
@@ -544,7 +545,7 @@ a {
544545
position: absolute;
545546
height: 3px;
546547
width: 100%;
547-
background: #fff;
548+
background: #3d3d3d;
548549
border-radius: 3px;
549550
transition: all 0.3s ease;
550551
}
@@ -564,3 +565,24 @@ a {
564565
.menu-button.active span:nth-child(3) {
565566
transform: rotate(-45deg) translate(7px, -7px);
566567
}
568+
569+
@media screen and (max-width: 768px) {
570+
#container {
571+
background: #fff !important;
572+
}
573+
574+
#main_content {
575+
color: #000 !important;
576+
}
577+
578+
#main_content h1,
579+
#main_content .sub_head,
580+
#main_content .info {
581+
color: #000 !important;
582+
}
583+
584+
#links a {
585+
color: #000 !important;
586+
border-color: #000 !important;
587+
}
588+
}

www/home.html

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<section id="main_content">
9797
<div id="head">
9898
<h1 style="font-family: fa;font-size: 300%;font-weight: 300;">
99-
<img src="img/whitelogo.png" style="width: 100px; margin-bottom: -30px;">
99+
<img src="img/whitelogo.png" style="width: 100px; margin-bottom: -30px;" id="logo-img">
100100
寻声</h1>
101101
<p class="sub_head">buttonwood的博客</p>
102102
<p class="info">这是我的个人博客,用于展示一些文章和搭建开发环境,欢迎参观使用</p>
@@ -114,5 +114,52 @@ <h1 style="font-family: fa;font-size: 300%;font-weight: 300;">
114114

115115
<script src="js/reg.js"></script>
116116
<script src="js/bideo.js"></script>
117+
<script>
118+
function handleMobileLayout() {
119+
const container = document.getElementById('container');
120+
const video = document.getElementById('background_video');
121+
const videoCover = document.getElementById('video_cover');
122+
const overlay = document.getElementById('overlay');
123+
const mainContent = document.getElementById('main_content');
124+
const logoImg = document.getElementById('logo-img');
125+
126+
if (isMobileDevice()) {
127+
// 移动端样式
128+
container.style.background = '#fff';
129+
video.style.display = 'none';
130+
videoCover.style.display = 'none';
131+
overlay.style.display = 'none';
132+
mainContent.style.color = '#000';
133+
document.querySelectorAll('#main_content h1, #main_content .sub_head, #main_content .info')
134+
.forEach(el => el.style.color = '#000');
135+
document.querySelectorAll('#links a')
136+
.forEach(el => {
137+
el.style.color = '#000';
138+
el.style.borderColor = '#000';
139+
});
140+
logoImg.src = 'img/logo.png'; // 切换为深色logo
141+
} else {
142+
// 桌面端样式
143+
container.style.background = 'none';
144+
video.style.display = 'block';
145+
videoCover.style.display = 'block';
146+
overlay.style.display = 'block';
147+
mainContent.style.color = '#fff';
148+
document.querySelectorAll('#main_content h1, #main_content .sub_head, #main_content .info')
149+
.forEach(el => el.style.color = '#fff');
150+
document.querySelectorAll('#links a')
151+
.forEach(el => {
152+
el.style.color = '#fff';
153+
el.style.borderColor = 'rgba(255, 255, 255, 0.20)';
154+
});
155+
logoImg.src = 'img/whitelogo.png'; // 切换回白色logo
156+
}
157+
}
158+
159+
// 初始化时执行
160+
handleMobileLayout();
161+
// 监听窗口大小变化
162+
window.addEventListener('resize', handleMobileLayout);
163+
</script>
117164
</body>
118165
</html>

0 commit comments

Comments
 (0)