I have this code:
pre[class*="language-"] {
top: 0;
position: relative;
border-radius: 3px;
}
#copybutton {
position: absolute;
right: 1em;
top: 1em;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
border: 0px transparent;
font-size: 0.725rem;
padding: 3px;
border-radius: 5px;
background-color: #ebebeb;
transition: background-color 0.25s ease-in-out;
}
<link href="https://prismjs.com/themes/prism.css" rel="stylesheet">
<script src="https://prismjs.com/prism.js"></script>
<pre class="language-js">
<button id="copybutton">Copy</button>
<code>const name = "" //a really really really really really really really really really really really really really really really really long </code>
</pre>
I want to position the button such that when the user scrolls the code horizontally, the button should not move prom its place. But when the user scrolls the page (not the code) it should move. CSS and JS answers appreciated. Please don't answer in jQuery.