Skip to content

Commit 78b0124

Browse files
committed
fix: 調整關閉按鈕位置並修復程式碼區塊複製按鈕滾動問題
1 parent 80d27df commit 78b0124

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta http-equiv="Expires" content="0">
99
<meta name="theme-color" content="#000000">
1010
<title>GitHub Copilot 教學專案</title>
11-
<link rel="stylesheet" href="style.css?v=20250603009">
11+
<link rel="stylesheet" href="style.css?v=20250603010">
1212
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
1313
<script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
1414
</head>
@@ -352,6 +352,6 @@ <h3 style="font-size: 1.25rem; font-weight: 600; color: #1d1d1f; margin-bottom:
352352
</div>
353353
</div>
354354

355-
<script src="script.js?v=20250603009"></script>
355+
<script src="script.js?v=20250603010"></script>
356356
</body>
357357
</html>

script.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ function addCopyButtons() {
183183
const codeBlocks = document.querySelectorAll('.markdown-content pre');
184184

185185
codeBlocks.forEach((block, index) => {
186+
// 確保 pre 元素是 relative 定位
187+
block.style.position = 'relative';
186188
// 獲取程式碼語言類型
187189
const codeElement = block.querySelector('code');
188190
const classList = codeElement.className.split(' ');

style.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,10 @@ body {
661661

662662
.markdown-close {
663663
position: sticky;
664-
top: -30px;
665-
margin-left: auto;
666-
margin-right: -30px;
664+
top: 20px;
665+
float: right;
666+
margin-top: -20px;
667+
margin-right: -20px;
667668
margin-bottom: 20px;
668669
width: 36px;
669670
height: 36px;
@@ -718,8 +719,9 @@ body {
718719

719720
@media (max-width: 768px) {
720721
.markdown-close {
721-
top: -20px;
722-
margin-right: -20px;
722+
top: 15px;
723+
margin-top: -10px;
724+
margin-right: -10px;
723725
width: 32px;
724726
height: 32px;
725727
border-radius: 16px;

0 commit comments

Comments
 (0)