Submit some intresting concepts to us using the button.. Submit Here!

Top 5 Code Box Deisgns in Blogger through JS and CSS [2022]

[5 DESIGN'S] How to add Code Box in Blogger through JS and CSS [2022] - Full Codes for Code Box
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

Heya,

CODE BOX DESIGN'S

Welcome to this new post and today i am going to provide you CSS codes to make a CODE BOX in Blogger.

So let's start with a quick Intro about Code Box...

Code Box in Blogger - Introduction

As you know that many of the sides UN blogger provides many of such type of codes which users require and if these codes are put an in normal boxes then may be user interaction will be less and the code may not be as good as highlighted. 
So as to give users and importance of code we often put them in a code box and there is a default script on our block about the codes which is not as much as attractive as we are going to make it today so stay tuned for this...
I am sharing you a code of code box which only requires CSS code and it can be added very easily in any of your post.

Code Box in Blogger - How to add these codes ?

So let's start this step by step-

Step1: Go to Blogger.com and Login to your account and select website..

Step2: Go to Themes and Then Edit HTML

Step3: Press CTRL+F and search for this code   ]]</b:skin> 

Step4: Paste the code that I will give above this ]]</b:skin>

Code Box in Blogger - Different Code styles for Code Box 

Style 1

CSS CODE : (For Theme)
.codebox1 { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; }.codebox1:hover { background-repeat:no-repeat; }

HTML CODE : (For Post)
<div class="codebox1">/*Paste here what you want to add*/</div>

Demo-
This is for Demo

 STYLE 2

CSS CODE : 
.codebox2{background: rgb(238, 238, 238); border-bottom-color: initial; border-bottom-style: initial; border-image: initial; border-left-color: initial; border-left-style: initial; border-radius: 10px; border-right-color: initial; border-right-style: initial; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-width: 5px 0px 0px; color: #444444; font-family: &quot;Courier New&quot;, Courier, monospace; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1.5em; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 12px; vertical-align: baseline;}

HTML CODE-
<div class="codebox2><span>/*Code Here */</span></div>
Demo-
This is for Demo

STYLE 3

CSS CODE :
btn.copy-code-button {    z-index: 2;    position: absolute;    font-size: 14px;    padding: 4px 5px;    border: none;    color: #333 !important;    background: #ffd012 !important;    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);    margin: 15px;  border-radius: 4px;}  pre{white-space:pre;word-wrap:normal;overflow:auto;font-size:14px;margin:0}pre,code{-webkit-user-select:text;-khtml-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;direction:ltr;}/* Highlighter */ code{padding:1.2em} .hljs,code{display:block;overflow-y:hidden;overflow-x:hidden;padding:1.2em;background:#2b2b2c;color:#fff;line-height:1.5;text-align:left;word-spacing:0;font-family:monospace;border-radius:5px;max-height:350px} .hljs:hover, .hljs:focus ,code:hover, code:focus{overflow-y:auto;overflow-x:auto} .hljs-name, .hljs-strong{font-weight:500} .hljs-code, .hljs-emphasis{font-style:italic} .hljs-tag{color:#62c8f3} .hljs-variable, .hljs-template-variable, .hljs-selector-id, .hljs-selector-class{color:#ade5fc} .hljs-string, .hljs-bullet{color:#a2fca2} .hljs-type, .hljs-title, .hljs-section, .hljs-attribute, .hljs-quote, .hljs-built_in, .hljs-builtin-name{color:#ffa} .hljs-number, .hljs-symbol, .hljs-bullet{color:#d36363} .hljs-keyword, .hljs-selector-tag, .hljs-literal{color:#fcc28c} .hljs-comment, .hljs-deletion, .hljs-code{color:#888} .hljs-regexp, .hljs-link{color:#c6b4f0} .hljs-meta{color:#fc9b9b} .hljs-deletion{background-color:#fc9b9b;color:#333} .hljs-addition{background-color:#a2fca2;color:#333} .hljs a{color:inherit} .hljs a:focus, .hljs a:hover{color:inherit;text-decoration:underline}mark  .hljs-attr,mark  .hljs-string,mark  .hljs-bullet{background-color:#e67e22;color:#fff} .hljs mark{background-color:#f24a4a;color:#fff;padding:2px 5px;border-radius:2px}.BLOG_mobile_video_class{display:none!important} .hljs mark span.hljs-number, .hljs mark span.hljs-comment, .hljs mark span.hljs-symbol, .hljs mark span.hljs-string, .hljs mark span.hljs-attr, .hljs mark span.hljs-keyword, .hljs mark span.hljs-name, .hljs mark span.hljs-tag{color:#fff !important;margin:.15rem 0}

JavaScript for Copy Button + Hljs Highlight Code -

function addCopyButtons(e){document.querySelectorAll("pre > code").forEach(function(t){var n=document.createElement("btn");n.className="copy-code-button",n.type="btn",n.innerText="Copied",n.addEventListener("click",function(){e.writeText(t.innerText).then(function(){n.blur(),n.innerText="copied",setTimeout(function(){n.innerText="Copied"},2e3)},function(e){n.innerText="Error"})});var o=t.parentNode;if(o.parentNode.classList.contains("highlight")){var r=o.parentNode;r.parentNode.insertBefore(n,r)}else o.parentNode.insertBefore(n,o)})}if(navigator&&navigator.clipboard)addCopyButtons(navigator.clipboard);else{var script=document.createElement("script");script.src="https://cdnjs.cloudflare.com/ajax/libs/clipboard-polyfill/2.7.0/clipboard-polyfill.promise.js",script.integrity="sha256-waClS2re9NUbXRsryKoof+F9qc1gjjIhc2eT7ZbIv94=",script.crossOrigin="anonymous",script.onload=function(){addCopyButtons(clipboard)},document.body.appendChild(script)}$('i[rel="pre"]').replaceWith(function(){return $("<pre><code>"+$(this).html()+"</code></pre>")});for(var pres=document.querySelectorAll("pre,code,kbd,blockquote,td"),i=0;i<pres.length;i++)pres[i].addEventListener("dblclick",function(){var e=getSelection(),t=document.createRange();t.selectNodeContents(this),e.removeAllRanges(),e.addRange(t)},!1);function downloadJSAtOnload(){var e=document.createElement("script");e.src="https://cdn.jsdelivr.net/gh/MohammadQt/Itheric@master/highlightpro.js",document.body.appendChild(e)}window.addEventListener?window.addEventListener("load",downloadJSAtOnload,!1):window.attachEvent?window.attachEvent("onload",downloadJSAtOnload):window.onload=downloadJSAtOnload; 

HTML CODE -

<pre><code>/*code here*/</code></pre>
Demo-
Code Box Style 3

STYLE 4

CSS CODE -
.post-body code.code,span.quot{background:#312b4a;box-shadow:inset 0 1px 4px #2a2542;padding:2px 5px;border-radius:3px;color:#fff;font-size:15px;white-space:normal;letter-spacing:-0.3px}.post-body code.code1,.post-body code.code2{background:#242038;border-left:4px solid #fda80c;padding:8px 10px;margin:20px auto;display:block;overflow:auto;border-radius:2px;white-space:nowrap;font-size:12px;line-height:1.5em;color:#dada8c}.post-body code.code2{border-left:0;border-radius:4px}.post-body code ul li{border:none;padding:2px 0}.post-body code ul{padding:0 20px}pre{box-shadow:0 -20px 20px -20px rgba(0,0,0,.054);margin:0 auto;position:relative;font-family:'source code pro',menlo,consolas,monaco,monospace;background:#0a3d62;color:rgba(255,255,255,.6);overflow:hidden;padding:50px 15px 15px 15px;border-radius:4px;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-ms-word-break:normal;word-break:normal;word-break:normal;-webkit-hyphens:none;-ms-hyphens:none;hyphens:none}pre code{font-size:12px;box-shadow:none;padding:0;background:0;white-space:pre;display:block;overflow-x:scroll;max-width:100%;min-height:60px;max-height:280px;line-height:1.5em}pre::before,pre::after,pre code::before,pre code::after{position:absolute}pre::after,pre code::before,pre code::after{content:'';width:20px;height:20px;border-radius:50%;top:10px}pre::before{content:attr(title);font-weight:500;border-radius:4px 4px 0 0;text-align:left;color:#fff;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.09,12L12,14.08V14.09L8.91,12L12,9.92V9.92L15.09,12M12,2C11.84,2 11.68,2.06 11.53,2.15L2.5,8.11C2.27,8.22 2.09,8.43 2,8.67V14.92C2,15.33 2,15.33 2.15,15.53L11.53,21.86C11.67,21.96 11.84,22 12,22C12.16,22 12.33,21.95 12.47,21.85L21.85,15.5C22,15.33 22,15.33 22,14.92V8.67C21.91,8.42 21.73,8.22 21.5,8.1L12.47,2.15C12.32,2.05 12.16,2 12,2M16.58,13L19.59,15.04L12.83,19.6V15.53L16.58,13M19.69,8.9L16.58,11L12.83,8.47V4.38L19.69,8.9M20.33,10.47V13.53L18.07,12L20.33,10.47M7.42,13L11.17,15.54V19.6L4.41,15.04L7.42,13M4.31,8.9L11.17,4.39V8.5L7.42,11L4.31,8.9M3.67,10.5L5.93,12L3.67,13.54V10.5Z' fill='%23fff'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:12px center;background-size:20px 20px;background-color:rgba(0,0,0,0.15);top:0;left:0;width:100%;height:40px;line-height:40px;padding:0 38px;box-sizing:border-box}pre::after{background-color:#ea756f;right:10px}code::before{background-color:#b38af5;right:35px}code::after{background-color:#81ce8e;right:60px}[rel="code"]{white-space:pre;overflow-x:scroll;display:block;line-height:1.8;margin:10px 0;background:#1d1b2b;border-radius:4px;padding:10px}[rel="code"]::-webkit-scrollbar,[rel="code"]:hover::-webkit-scrollbar{height:0}mark{background-color:#ff4757;border-radius:2px;padding:0 4px;color:#fff}.spoiler-amp{margin:10px 0}.spoiler-amp h4.spoiler-button{color:#222;font-size:14px;font-weight:500;outline:none;margin:0;line-height:1.5em;border-radius:50px;padding:8px 30px;-moz-border-radius:50px}.spoiler-amp h4.spoiler-button:before{content:"";position:absolute;left:15px;top:50%;margin-top:-7px;border:7px solid;border-color:transparent transparent transparent #444}.spoiler-amp h4.spoiler-button:after{content:"\0002B";position:absolute;font-size:20px;line-height:20px;top:50%;margin-top:-10px;text-align:right;right:15px}.spoiler-amp section[expanded] h4.spoiler-button:after{content:"\02013"}amp-accordion section{margin:10px 0}.spoiler-amp amp-accordion div.isi{height:auto;margin:20px 10px;padding:0 0 0 20px;border-left:3px dotted #f0f0f0}

HTML CODE -
<pre><code>/*code here*/</code></pre>

Demo-

Code Box Style 4

STYLE 5

CSS CODE -
.cBox{position:relative;background:#fff;width:100%;border-radius:6px;box-shadow:0 10px 40px rgba(0,0,0,.1);padding:20px;margin:30px 0 30px}.cBox .cBoxH{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}.cBox .cBoxH span{margin:0;font-weight:700;font-family:inherit;font-size:1.1rem}.cBox .cBoxB{cursor:pointer;display:inline-flex;align-items:center;padding:12px;outline:0;border:0;border-radius:50%;background:#056aff;transition:all .3s ease;-webkit-transition:all .3s ease}.cBox .cBoxB:hover{opacity:.8}.cBox .cBoxB .icn{flex-shrink:0;display:inline-block;width:18px;height:18px;background-image:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23fefefe' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' viewBox='0 0 24 24'><rect x='5.54615' y='5.54615' width='16.45385' height='16.45385' rx='4'/><path d='M171.33311,181.3216v-8.45385a4,4,0,0,1,4-4H183.787' transform='translate(-169.33311 -166.86775)'/></svg>");background-size:cover;background-repeat:no-repeat;background-position:center}.cBox .cBoxB.copied{background:#2dcda7}.cBox .cBoxB.copied .icn{background-image:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23fefefe' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' viewBox='0 0 24 24'><path d='M22 11.07V12a10 10 0 1 1-5.93-9.14'/><polyline points='23 3 12 14 9 11'/></svg>")}.cBox pre{min-height:350px;margin:0;background:#f6f6f6;padding:15px;border-radius:5px;color:#08102b;font-size:.8rem;font-family:monospace;overflow:scroll;scroll-behavior:smooth;scroll-snap-type:x mandatory;-ms-overflow-style:none;-webkit-overflow-scrolling:touch}.cBox pre::before, .cBox pre::after{content:''}.darkMode .cBox{background:#2d2d30}.darkMode .cBox pre{background:#252526;color:#fffdfc}.tNtf span{position:fixed;left:24px;bottom:-70px;display:inline-flex;align-items:center;text-align:center;justify-content:center;margin-bottom:20px;z-index:99981;background:#323232;color:rgba(255,255,255,.8);font-size:14px;font-family:inherit;border-radius:3px;padding:13px 24px; box-shadow:0 5px 35px rgba(149,157,165,.3);opacity:0;transition:all .1s ease;animation:slideinwards 2s ease forwards;-webkit-animation:slideinwards 2s ease forwards}@media screen and (max-width:500px){.tNtf span{margin-bottom:20px;left:20px;right:20px;font-size:13px}}@keyframes slideinwards{0%{opacity:0}20%{opacity:1;bottom:0}50%{opacity:1;bottom:0}80%{opacity:1;bottom:0}100%{opacity:0;bottom:-70px;visibility:hidden}}@-webkit-keyframes slideinwards{0%{opacity:0}20%{opacity:1;bottom:0}50%{opacity:1;bottom:0}80%{opacity:1;bottom:0}100%{opacity:0;bottom:-70px;visibility:hidden}}

HTML CODE - (For theme above </body>)
<div id='toastNotif' class='tNtf'></div><script>/*<![CDATA[*/  function copyC(e,t){var o=document.getElementById(e),n=document.getElementById(t),e=getSelection(),t=document.createRange();e.removeAllRanges(),t.selectNodeContents(n),e.addRange(t),document.execCommand("copy"),e.removeAllRanges(),o.classList.add("copied"),document.getElementById("toastNotif").innerHTML="<span>Copied to Clipboard!</span>",setTimeout(()=>{o.classList.remove("copied")},3e3)} /*]]>*/</script>

HTML POST CODE -
<!--[ Code Box 1 ]--><div class='cBox'>  <div class='cBoxH'>    <!--[ Heading ]-->    <span>HTML</span>    <!--[ Copy Button ]-->    <button id='copy1' class='cBoxB' onclick="copyC('copy1','code1')">      <i class='icn'></i>    </button>  </div>  <!--[ Content ]-->  <div id='code1'>    <pre>Your_codes_here</pre>  </div></div>
<!--[ Code Box 2 ]--><div class='cBox'>  <div class='cBoxH'>    <!--[ Heading ]-->    <span>CSS</span>    <!--[ Copy Button ]-->    <button id='copy2' class='cBoxB' onclick="copyC('copy2','code2')">      <i class='icn'></i>    </button>  </div>  <!--[ Content ]-->  <div id='code2'>    <pre>Your_codes_here</pre>  </div></div>
<!--[ Code Box 3 ]--><div class='cBox'>  <div class='cBoxH'>    <!--[ Heading ]-->    <span>JS</span>    <!--[ Copy Button ]-->    <button id='copy3' class='cBoxB' onclick="copyC('copy3','code3')">      <i class='icn'></i>    </button>  </div>  <!--[ Content ]-->  <div id='code3'>    <pre>Your_codes_here</pre>  </div></div>
Demo-
Code Box Style 5

Code Box in Blogger - Conclusion


So that's all for today and I hope you get your best loving Code Box for free🥹

Please rate below about the article and comment down for suggestions and errors in our codes.

Thanks

About the Author

Hi, I am Anand Nawal and my motive is to give you the best guide over your Query☺️

Post a Comment

Cookie Consent
We have to use your Cookies to store your Browser Info to serve you Better Experience and make WebSite Fast..
Oops!
Your Internet Connection is weakened. Please try Refreshing your Browser or Check your Internet Connection...
AdBlock Detected!
We detect that your are using some kind of AdBlocker which we can't allow.
The Revenue we generate with Ads is important for our WebSite to manage funds...
Site is Blocked
Sorry! This site is not available in your country.