LiuShen ha revisionato questo gist 6 months ago. Vai alla revisione
                
            
            Nessuna modifica
                
                
                
                    
                
                LiuShen ha revisionato questo gist 10 months ago. Vai alla revisione
                
                    1 file changed, 1 insertion, 1 deletion
click-only-reflesh-picture.html
| @@ -29,7 +29,7 @@ | |||
| 29 | 29 | const image = document.getElementById('dynamicImage'); | |
| 30 | 30 | ||
| 31 | 31 | image.addEventListener('click', () => { | |
| 32 | - | image.src = `https://birdteam.net/heisi.php?timestamp=${new Date().getTime()}`; // 更新图片地址 | |
| 32 | + | image.src = `https://birdteam.net/heisi.php?timestamp=${new Date().getTime()}`; // 更新图片地址,这个时间戳的参数并不是api所需,而是为了防止缓存,而添加了个参数,使url不一样 | |
| 33 | 33 | }); | |
| 34 | 34 | </script> | |
| 35 | 35 | </body> | |
                
                
                
                    
                
                LiuShen ha revisionato questo gist 10 months ago. Vai alla revisione
                
                    1 file changed, 36 insertions
click-only-reflesh-picture.html(file creato)
| @@ -0,0 +1,36 @@ | |||
| 1 | + | <!DOCTYPE html> | |
| 2 | + | <html lang="en"> | |
| 3 | + | <head> | |
| 4 | + | <meta charset="UTF-8"> | |
| 5 | + | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| 6 | + | <title>局部刷新图片</title> | |
| 7 | + | <style> | |
| 8 | + | body { | |
| 9 | + | display: flex; | |
| 10 | + | justify-content: center; | |
| 11 | + | align-items: center; | |
| 12 | + | margin: 0; | |
| 13 | + | height: 100vh; | |
| 14 | + | background-color: #f4f4f9; | |
| 15 | + | } | |
| 16 | + | img { | |
| 17 | + | max-width: 90%; /* 限制图片最大宽度为屏幕的 90% */ | |
| 18 | + | height: auto; /* 保持图片的宽高比 */ | |
| 19 | + | border: 2px solid #333; | |
| 20 | + | box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | |
| 21 | + | cursor: pointer; /* 鼠标悬停显示为手型 */ | |
| 22 | + | } | |
| 23 | + | </style> | |
| 24 | + | </head> | |
| 25 | + | <body> | |
| 26 | + | <img id="dynamicImage" src="https://birdteam.net/heisi.php" alt="动态图片" title="点击刷新图片"> | |
| 27 | + | ||
| 28 | + | <script> | |
| 29 | + | const image = document.getElementById('dynamicImage'); | |
| 30 | + | ||
| 31 | + | image.addEventListener('click', () => { | |
| 32 | + | image.src = `https://birdteam.net/heisi.php?timestamp=${new Date().getTime()}`; // 更新图片地址 | |
| 33 | + | }); | |
| 34 | + | </script> | |
| 35 | + | </body> | |
| 36 | + | </html> | |