-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add copy-to-clipboard button to code blocks #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
2e06bac
93c76d0
7dce870
1e5d997
da60caf
5173cfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,7 +319,7 @@ pre > code:focus { | |
| } */ | ||
|
|
||
| /* Code */ | ||
| /* .highlight .hll { background-color: #ffc; | ||
| /* .highlight .hll { background-color: #ffc; | ||
| .highlight .c { color: #999; } | ||
| .highlight .err { color: #a00; background-color: #faa } | ||
| .highlight .k { color: #069; } | ||
|
|
@@ -699,3 +699,51 @@ pre.highlight { | |
| .highlight .gi { | ||
| color: #a6e22e; | ||
| } | ||
|
|
||
| /* Copy to clipboard button */ | ||
| pre { | ||
| position: relative; | ||
| } | ||
|
|
||
| .copy-btn { | ||
| position: absolute; | ||
| top: 8px; | ||
| right: 8px; | ||
|
Comment on lines
+709
to
+711
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I’d prefer to avoid
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to go with the wrapper approach instead of |
||
| min-width: 60px; | ||
| padding: 4px 10px; | ||
| font-family: inherit; | ||
| font-size: 12px; | ||
| color: #abb2bf; | ||
| background: transparent; | ||
| border: 1px solid #abb2bf; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| opacity: 0; | ||
| text-align: center; | ||
| transition: opacity 0.15s ease-in-out; | ||
|
joshbuchea marked this conversation as resolved.
|
||
| } | ||
|
|
||
| pre:hover .copy-btn, | ||
| .copy-btn:focus { | ||
| opacity: 1; | ||
| } | ||
|
joshbuchea marked this conversation as resolved.
|
||
|
|
||
| .copy-btn:hover { | ||
| background: rgba(171, 178, 191, 0.1); | ||
| } | ||
|
|
||
| @media (hover: none) { | ||
| .copy-btn { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| .visually-hidden { | ||
| clip-path: inset(50%); | ||
| height: 1px; | ||
| width: 1px; | ||
| overflow: hidden; | ||
| position: absolute; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.