Skip to content

Commit 3bfd648

Browse files
committed
fixed copy code functionality
1 parent 62975f8 commit 3bfd648

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

css/post.css

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
font-size: 0.9em;
5454
line-height: 1.5;
5555
margin: 1.5em 0;
56-
position: relative;
56+
position: relative !important;
57+
/* Must stay relative for the copy button to anchor */
5758
}
5859

5960
.post-content-main pre code {
@@ -141,10 +142,12 @@ aside .tech-stack {
141142
}
142143

143144
/* ===== CUSTOM COPY-TO-CLIPBOARD BUTTON STYLING ===== */
144-
.copy-code-btn {
145-
position: absolute;
146-
top: 0.5rem;
147-
right: 0.5rem;
145+
.post-content-main pre>.copy-code-btn {
146+
position: absolute !important;
147+
top: 0.5rem !important;
148+
right: 0.5rem !important;
149+
left: auto !important;
150+
bottom: auto !important;
148151
padding: 0.4rem;
149152
background: transparent;
150153
color: var(--code-text-color);
@@ -156,17 +159,18 @@ aside .tech-stack {
156159
/* Always clearly visible */
157160
transition: opacity 0.2s, color 0.2s, background-color 0.2s;
158161
border-radius: 4px;
162+
z-index: 10;
159163
}
160164

161-
.post-content-main pre:hover .copy-code-btn {
165+
.post-content-main pre:hover>.copy-code-btn {
162166
opacity: 1;
163167
}
164168

165-
.copy-code-btn:hover {
169+
.post-content-main pre>.copy-code-btn:hover {
166170
background-color: rgba(128, 128, 128, 0.3);
167171
}
168172

169-
.copy-code-btn.copied {
173+
.post-content-main pre>.copy-code-btn.copied {
170174
color: var(--link-color);
171175
opacity: 1;
172176
}

0 commit comments

Comments
 (0)