Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="root">
 <div class="container">
  <p></p>
  <div class="copy-wrapper">
   <input id="copyText" type="text" placeholder="Write Here..">
   <button id="btn-furkan">COPY</button>
  </div>
  <textarea name="name" id="name" cols="30" rows="10" placeholder="Paste Here.."></textarea>
 </div>
</div>
              
            
!

CSS

              
                * {
 padding: 0;
 margin: 0;
}

#root {
 height: 100vh;
 display: flex;
 justify-content: center;
 align-items: center;
 background: #fdf0ed;
 color: #e8795d;
}

.container {
 display: flex;
 flex-direction: column;
 position: relative;
}

#btn-furkan {
 padding: 10px;
 background: #fdf0ed;
 color: #e8795d;
 border: 1px solid #e8795d;
 border-radius: 3px;
 cursor: pointer;
 transition: all 0.5s;
 font-size: 20px;
 flex: 1;
 margin-left: 10px;
}

#btn-furkan:hover {
 background: #e8795d;
 color: #fdf0ed;
}
.copy-wrapper {
 display: flex;
 justify-content: center;
 align-items: stretch;
 margin-bottom: 10px;
}

h1 {
 margin-bottom: 50px;
}
textarea {
 background: #fdf0ed;
 padding: 5px;
 font-size: 20px;
}
input {
 background: #fdf0ed;
 padding: 5px;
 font-size: 20px;
 border: 1px solid #e8795d;
 width: 60%;
}

.notification {
 top: 50px;
 right: 20px;
}

              
            
!

JS

              
                const button = document.getElementById("btn-furkan");
const input = document.getElementById("copyText");

let copyText = "";
const withExecCopy = (text) => {
 const textArea = document.createElement("textarea");
 textArea.value = text;

 // Avoid scrolling to bottom
 textArea.style.top = "0";
 textArea.style.left = "0";
 textArea.style.position = "fixed";

 document.body.appendChild(textArea);
 textArea.focus();
 textArea.select();

 try {
  var successful = document.execCommand("copy");
  var msg = successful ? "successful" : "unsuccessful";
  console.log("Fallback: Copying text command was " + msg);
  text;
 } catch (err) {
  console.error("Fallback: Oops, unable to copy", err);
 }

 document.body.removeChild(textArea);
};

const withClipboardAPICopy = (text) => {
 navigator.clipboard.writeText(text).then(
  function () {
   console.log("Async: Copying to clipboard was successful!");
  },
  function (err) {
   console.error("Async: Could not copy text: ", err);
  }
 );
};

button.addEventListener("click", (e) => {
 button.textContent = "COPIED";

 setTimeout(() => {
  button.textContent = "COPY";
 }, 2000);

 // withClipboardAPICopy(copyText);

 withExecCopy(copyText);
});

input.addEventListener("change", (e) => {
 console.log(e.target.value);
 copyText = e.target.value;
});

              
            
!
999px

Console