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

Auto Save

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='app'></div>
<div class='background'></div>
<!-- Background resizes in proportion to the windows width  -->

<!-- 
Made by Ying.
GitHub: https://github.com/yingmo55 

Originally used in this project. Modified for CodePen: 
https://github.com/yingmo55/which-language-first

Message in the binary code: 
print("hello world!")
-->

              
            
!

CSS

              
                /* Global margin and padding reset */
* {
	margin: 0;
	padding: 0;
}

/* Background color */

.background {
	position: absolute;
	width: 100vw;
	height: 100vh;
	background-color: rgb(5, 5, 5);
}


/* Background Binary Component */
.binary-background {
    min-width: 390px;
    height: 100vh;
    display: inline-flex;
    overflow: hidden;
}

.binary {
    opacity: 90%;
    filter: blur(1px);
    font-family: 'Noto Sans', sans-serif;
    font-size: 30px;
    z-index: 1;
    width: 10px;
    max-height: 100vh;
    padding: 5px;
    margin: 0 5px;
    background: linear-gradient(to bottom,#06414e, #048ABF, #80e6f1) no-repeat;
    background-clip: text;
		-webkit-background-clip: text;
    color: transparent;
    -webkit-text: transparent;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Background Component  */
.mainBG{
    height: 100vh;
    overflow: hidden;
}

#overlay {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}


.background1 {
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    max-height: 100vh;
    width: 100vw;
    display: flex;
    overflow: hidden;
    justify-content: center;
}

              
            
!

JS

              
                import React, { useState, useEffect, useRef } from "https://cdn.skypack.dev/react@17.0.1";
import ReactDOM from "https://cdn.skypack.dev/react-dom@17.0.1";

// Background Binary Component
function BackgroundBinary() {
    return(
        <div className="binary-background" role="presentation">
            <p className="binary">0 1 1 1 0 0 0 0  0 1 1 1 0 0 1 0</p>
            <p className="binary">0 1 1 0 1 0 0 1</p>
            <p className="binary">0 1 1 0 1 1 1 0  0 1 1 1 0 1 0 0  0 0 1 0 1 0 0 0 </p>
            <p className="binary">0 0 1 0 0 0 1 0  0 1 1 0 1 0 0 0 </p>
            <p className="binary">0 1 1 0 0 1 0 1</p>
            <p className="binary">0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0</p>
            <p className="binary">0 1 1 0 1 1 1 1 </p>
            <p className="binary">0 0 1 0 0 0 0 0 0 1 1 1 0 1 1 1</p>  
            <p className="binary"> 1 1 1 1 1 0 0 0 0 1 1 0 0     1 1 1 1 0</p>
            <p className="binary">0 1 1 0 1 1 1 1</p>
            <p className="binary">0 1 1 1 0 0 1 0 
0 1 1 0 1 1 0 0</p>
            <p className="binary">0 1 1 0 0 1 0 0 
0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 </p>
            <p className="binary">0 0 1 0 1 0 0 1</p>
            <div id='background-color'></div>
        </div>
    )
};

// Background component
// add the following when you use it as a separate component
// import React, {useRef, useState, useEffect} from 'react'; 
// import BackgroundBinary from '../BackgroundBinary/BackgroundBinary';

function Background() {
    const ref = useRef(null);
    const [width, setWidth] = useState(0);
    const [screenWidth, setScreenWidth] = useState(window.innerWidth);

    useEffect(() => {
        setWidth(ref.current.offsetWidth);
    }, [screenWidth]);

    useEffect(() => {
        window.addEventListener('resize', setScreenWidth);
         
        return(() => {
            window.removeEventListener('resize', setScreenWidth);
        })
      }, [screenWidth])

    const numOfRender = Math.floor(width / 390) + 1;
    let backgroundArray = [];
    for (let i=0; i < numOfRender; i++){
        backgroundArray.push(<BackgroundBinary key={i} />);
        }
   const background = backgroundArray.map(item => item)

    return(
    <div id='mainBG'>
        <div className='background1' ref={ref} role="presentation">
        <div id='overlay'></div>
        {background}
        </div>
    </div>
    )
}

ReactDOM.render(<Background />, document.getElementById('app'));
              
            
!
999px

Console