Skip to content

Commit f6e0fee

Browse files
committed
fix: 修正複製按鈕為固定位置,避免滾動時移動
1 parent 4ee0c8a commit f6e0fee

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ <h3 style="font-size: 1.25rem; font-weight: 600; color: #1d1d1f; margin-bottom:
7878
<details style="margin-top: 28px; background: #f5f5f7; padding: 24px; border-radius: 16px; border: none;">
7979
<summary style="cursor: pointer; font-weight: 600; color: #007aff; font-size: 1rem;">Agent 快速設置指令(點擊展開)</summary>
8080
<div style="position: relative;">
81-
<button onclick="copyAgentPrompt()" style="position: absolute; top: 15px; right: 15px; padding: 5px 10px; background: #007aff; color: white; border: none; border-radius: 20px; font-size: 12px; cursor: pointer; z-index: 10;">
81+
<button onclick="copyAgentPrompt()" style="position: fixed; top: auto; bottom: 20px; right: 20px; padding: 8px 16px; background: #007aff; color: white; border: none; border-radius: 20px; font-size: 12px; cursor: pointer; z-index: 1000; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3); display: none;">
8282
複製
8383
</button>
8484
<pre id="agentPrompt" style="margin-top: 10px; background: white; padding: 15px; padding-right: 60px; border-radius: 5px; font-size: 0.9rem; overflow-x: auto;">請幫我設置 GitHub Copilot 教學專案環境:

script.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ async function copyAgentPrompt() {
4242
}
4343
}
4444

45+
// 監聽 details 元素的開啟/關閉
46+
document.addEventListener('DOMContentLoaded', function() {
47+
const detailsElement = document.querySelector('details');
48+
const copyButton = detailsElement.querySelector('button[onclick="copyAgentPrompt()"]');
49+
50+
// 監聽 toggle 事件
51+
detailsElement.addEventListener('toggle', function() {
52+
if (detailsElement.open) {
53+
copyButton.style.display = 'block';
54+
} else {
55+
copyButton.style.display = 'none';
56+
}
57+
});
58+
});
59+
4560
// 儲存和取得捲動位置
4661
function saveScrollPosition(path, position) {
4762
localStorage.setItem(`scroll_${path}`, position);

0 commit comments

Comments
 (0)