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