How to make codebox with copy Code blogger
how to make code box in blogger
Follow these simple steps to add a code box with beautiful copy button to your Blogger website:
Step 1: Log in to your Blogger dashboard
Go to your Blogger post and select the Html view you want to add the code box.
Step 2: Access the HTML View And Fine important add The Code
To add BRO code, use HTML code generator and press it, then the code will be added
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Code Box with Copy Button</title>
<style>
/* 3D Code Block Styling */
pre {
background-color: #1e1e1e; /* Dark background */
color: #ffffff; /* White text */
border: none;
padding: 20px;
font-family: monospace;
white-space: pre-wrap;
word-wrap: break-word;
overflow: auto;
/* 3D Effect */
position: relative;
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.5), -5px -5px 15px rgba(255, 255, 255, 0.1);
border-radius: 10px;
transform: translateZ(0px);
transition: transform 0.2s;
}
pre:hover {
transform: translateZ(15px); /* Hover effect to make the box "pop" */
}
/* Button Styling */
button {
margin-top: 10px;
padding: 10px;
font-size: 16px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
/* Copy Alert Styling */
.bottom-alert {
position: fixed;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
background-color: #007bff; /* Blue background */
color: #fff;
padding: 10px 20px;
text-align: center;
display: none;
font-size: 16px;
border-radius: 9px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
z-index: 999999999999;
}
/* Strong Tag Styling */
strong {
color: #ffcc00; /* Custom color for <strong> */
}
</style>
</head>
<!-- 3D Code Box with Strong Tag -->
<pre id="codeOutput">Here is some <strong>important</strong> code you can copy!</pre>
<!-- Copy Code Button -->
<button onclick="copyToClipboard()">Copy Code</button>
<!-- Bottom Alert for Copying -->
<div class='bottom-alert' id='bottomAlert'>Code Copied!</div>
<script>
function copyToClipboard() {
var codeElement = document.getElementById("codeOutput");
var tempTextArea = document.createElement("textarea");
tempTextArea.value = codeElement.textContent; // Copy the plain text content
document.body.appendChild(tempTextArea);
tempTextArea.select();
tempTextArea.setSelectionRange(0, 99999);
document.execCommand("copy");
document.body.removeChild(tempTextArea);
showBottomAlert();
}
function showBottomAlert() {
var bottomAlert = document.getElementById("bottomAlert");
bottomAlert.style.display = "block";
setTimeout(function() {
bottomAlert.style.display = "none";
}, 3000);
}
</script>
</html>
Code Copied!

Join the conversation