Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 class="wrapper">
  <div class="one d-flex align-items-center pl-5 bg-light-tiny">
    <div>
    <h1 class="mb-2 mt-0">CSS Grid-ient 2</h1>
    <p class="lead mb-2">Grid based CSS gradients, in a CSS grid.</p>
    </div>
  </div>
  <div class="two bg-codepen"></div>
  <div class="three bg-light-blue"></div>
  <div class="four bg-dg"></div>
  <div class="five bg-codepen-light"></div>
  <div class="six bg-dark-gray"></div>
  <div class="seven bg-light-large"></div>
  <div class="eight bg-dark-large"></div>
  <div class="nine d-flex align-items-center bg-light-basic pl-5">
    <div>
      <p class="lead font-weight-bold mb-2">Click to copy the CSS</p>
      <p class="mb-2">
        More grid based gradients (with color!) at 
        <a href="https://www.gradientmagic.com/collection/basicgrid" class="text-dark" target="_blank"><u>Gradient Magic</u></a>
      </p>
      <p><a href="https://codepen.io/TheCSSKing/full/ZEzBbGo" target="_blank" class="text-dark"><u>The Original CSS Grid-ient</u></a></p>
    </div>
  </div>
</div>
<div id="copyBox"></div>
              
            
!

CSS

              
                body {
  height: 100vh;
  margin: 0;
}

#copyBox {
  display: none;
}

.wrapper {
  display: grid;
  height: 100%;
  grid-gap: 0px;
  grid-template-columns: repeat(3,1fr);
  grid-template-rows: 33% 33% 34%;
  
  > div {
    // background-color: white;
    cursor: pointer;
    // border: 1px solid #333;
  }
}

.bg-codepen {
  background-image: repeating-linear-gradient(90deg, hsla(168,0%,63%,0.09) 0px, hsla(168,0%,63%,0.09) 1px,transparent 1px, transparent 96px),repeating-linear-gradient(0deg, hsla(168,0%,63%,0.09) 0px, hsla(168,0%,63%,0.09) 1px,transparent 1px, transparent 96px),repeating-linear-gradient(0deg, hsla(168,0%,63%,0.09) 0px, hsla(168,0%,63%,0.09) 1px,transparent 1px, transparent 12px),repeating-linear-gradient(90deg, hsla(168,0%,63%,0.09) 0px, hsla(168,0%,63%,0.09) 1px,transparent 1px, transparent 12px),linear-gradient(90deg, rgb(20,20,20),rgb(20,20,20));
}

.bg-codepen-light {
  background-image: repeating-linear-gradient(90deg, hsla(352,0%,68%,0.09) 0px, hsla(352,0%,68%,0.09) 1px,transparent 1px, transparent 96px),repeating-linear-gradient(0deg, hsla(352,0%,68%,0.09) 0px, hsla(352,0%,68%,0.09) 1px,transparent 1px, transparent 96px),repeating-linear-gradient(0deg, hsla(352,0%,68%,0.09) 0px, hsla(352,0%,68%,0.09) 1px,transparent 1px, transparent 12px),repeating-linear-gradient(90deg, hsla(352,0%,68%,0.09) 0px, hsla(352,0%,68%,0.09) 1px,transparent 1px, transparent 12px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-dg {
background-image: repeating-linear-gradient(0deg, rgba(166,166,166, 0.15) 0px, rgba(166,166,166, 0.15) 1px,transparent 1px, transparent 11px),repeating-linear-gradient(90deg, rgba(166,166,166, 0.15) 0px, rgba(166,166,166, 0.15) 1px,transparent 1px, transparent 11px),linear-gradient(90deg, rgb(20,20,20),rgb(20,20,20));
}

.bg-light-blue {
  background-image: repeating-linear-gradient(90deg, rgba(11,123,222,0.05) 0px, rgba(11,123,222,0.05) 1px,transparent 1px, transparent 60px),repeating-linear-gradient(0deg, rgba(11,123,222,0.05) 0px, rgba(11,123,222,0.05) 1px,transparent 1px, transparent 60px),repeating-linear-gradient(0deg, rgba(11,123,222,0.05) 0px, rgba(11,123,222,0.05) 1px,transparent 1px, transparent 20px),repeating-linear-gradient(90deg, rgba(11,123,222,0.05) 0px, rgba(11,123,222,0.05) 1px,transparent 1px, transparent 20px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-dark-gray {
  background-image: repeating-linear-gradient(90deg, transparent 0px, transparent 1px,rgba(135, 135, 135,0.06) 1px, rgba(135, 135, 135,0.06) 6px),repeating-linear-gradient(0deg, transparent 0px, transparent 1px,rgba(135, 135, 135,0.06) 1px, rgba(135, 135, 135,0.06) 6px),repeating-linear-gradient(0deg, transparent 0px, transparent 1px,rgba(135, 135, 135,0.06) 1px, rgba(135, 135, 135,0.06) 18px),repeating-linear-gradient(90deg, transparent 0px, transparent 1px,rgba(135, 135, 135,0.06) 1px, rgba(135, 135, 135,0.06) 18px),linear-gradient(90deg, hsl(105,0%,5%),hsl(105,0%,5%));
}


.bg-light-md {
  background-image: repeating-linear-gradient(0deg, rgba(219, 219, 219,0.2) 0px, rgba(219, 219, 219,0.2) 1px,transparent 1px, transparent 21px),repeating-linear-gradient(90deg, rgba(219, 219, 219,0.2) 0px, rgba(219, 219, 219,0.2) 1px,transparent 1px, transparent 21px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-light-four {
  background-image: repeating-linear-gradient(90deg, rgba(218, 218, 218,0.15) 0px, rgba(218, 218, 218,0.15) 1px,transparent 1px, transparent 30px),repeating-linear-gradient(0deg, rgba(218, 218, 218,0.15) 0px, rgba(218, 218, 218,0.15) 1px,transparent 1px, transparent 30px),repeating-linear-gradient(0deg, rgba(218, 218, 218,0.15) 0px, rgba(218, 218, 218,0.15) 1px,transparent 1px, transparent 15px),repeating-linear-gradient(90deg, rgba(218, 218, 218,0.15) 0px, rgba(218, 218, 218,0.15) 1px,transparent 1px, transparent 15px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-light-basic {
  background-image: repeating-linear-gradient(0deg, rgba(219, 219, 219,0.2) 0px, rgba(219, 219, 219,0.2) 1px,transparent 1px, transparent 21px),repeating-linear-gradient(90deg, rgba(219, 219, 219,0.2) 0px, rgba(219, 219, 219,0.2) 1px,transparent 1px, transparent 21px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-light-tiny {
  background-image: repeating-linear-gradient(90deg, rgba(198, 198, 198,0.05) 0px, rgba(198, 198, 198,0.05) 1px,transparent 1px, transparent 5px),repeating-linear-gradient(0deg, rgba(198, 198, 198,0.05) 0px, rgba(198, 198, 198,0.05) 1px,transparent 1px, transparent 5px),repeating-linear-gradient(0deg, rgba(198, 198, 198,0.06) 0px, rgba(198, 198, 198,0.06) 1px,transparent 1px, transparent 15px),repeating-linear-gradient(90deg, rgba(198, 198, 198,0.06) 0px, rgba(198, 198, 198,0.06) 1px,transparent 1px, transparent 15px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-light-sm {
  background-image: repeating-linear-gradient(0deg, hsla(134,0%,63%,0.08) 0px, hsla(134,0%,63%,0.08) 1px,transparent 1px, transparent 9px),repeating-linear-gradient(90deg, hsla(134,0%,63%,0.08) 0px, hsla(134,0%,63%,0.08) 1px,transparent 1px, transparent 9px),linear-gradient(90deg, rgb(255,255,255),rgb(255,255,255));
}

.bg-dark-large {
  background-image: repeating-linear-gradient(0deg, rgb(47, 47, 47) 0px, rgb(47, 47, 47) 1px,transparent 1px, transparent 51px),repeating-linear-gradient(90deg, rgb(47, 47, 47) 0px, rgb(47, 47, 47) 1px,transparent 1px, transparent 51px),linear-gradient(90deg, hsl(40,0%,7%),hsl(40,0%,7%));
}

.bg-light-large {
background-image: repeating-linear-gradient(90deg, rgba(166,166,166, 0.09) 0px, rgba(166,166,166, 0.09) 1px,transparent 1px, transparent 104px),repeating-linear-gradient(0deg, rgba(166,166,166, 0.09) 0px, rgba(166,166,166, 0.09) 1px,transparent 1px, transparent 104px),repeating-linear-gradient(0deg, rgba(166,166,166, 0.14) 0px, rgba(166,166,166, 0.14) 1px,transparent 1px, transparent 52px),repeating-linear-gradient(90deg, rgba(166,166,166, 0.14) 0px, rgba(166,166,166, 0.14) 1px,transparent 1px, transparent 52px),linear-gradient(45deg, rgb(255,255,255),rgb(255,255,255));
}
              
            
!

JS

              
                let wrapper = document.querySelector('.wrapper');

function copyText(text){
  let copyBox = document.querySelector('#copyBox');
  copyBox.style['display'] = 'block';
  copyBox.innerHTML = text;
  selectText('copyBox')
  document.execCommand('copy');
  copyBox.style['display'] = 'none';
  toastr.success('CSS Copied to Clipboard')
}

// https://stackoverflow.com/questions/985272/selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
function selectText(node) {
    node = document.getElementById(node);

    if (document.body.createTextRange) {
        const range = document.body.createTextRange();
        range.moveToElementText(node);
        range.select();
    } else if (window.getSelection) {
        const selection = window.getSelection();
        const range = document.createRange();
        range.selectNodeContents(node);
        selection.removeAllRanges();
        selection.addRange(range);
    } else {
        console.warn("Could not select text in node: Unsupported browser.");
    }
}

let copyCSS = function(e){
  console.log(e);

  let style = getComputedStyle(e.target);
  let fullCSS = `background-image: ${style.backgroundImage}`

  copyText(fullCSS)
}

wrapper.addEventListener('click', copyCSS, false);
              
            
!
999px

Console