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 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

              
                
    <nav class="navbar navbar-light bg-color">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
  <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
    <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
      <li class="nav-item active">
        <a class="nav-link" href="#home">Home<span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#blues">The Blues</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#greens">The Greens</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#reds">The Reds</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#yellows">The Yellows</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#rest">The Rest</a>
      </li>
    </ul>
  </div>
</nav>    
    
            <div class="content">
       
               <div class="shapes">
				<svg class="scene" width="100%" height="100vh" preserveAspectRatio="none" viewBox="0 0 1440 800">
					<path class="morpho" d="M 1066,436 C 1051,543.8 973.2,656.2 873.6,700.1 756.6,751.7 600.9,725 492.4,657.4 431.5,619.5 387.5,546.9 376.7,476 360.3,368.3 377.9,229.2 462.5,160.5 589.5,57.34 815.4,42.24 952.4,131.7 1044,190.8 1081,328.8 1066,436 Z" pathdata:id="M 1041,450.4 C 1023,547.7 992.8,667.7 905.7,714.5 793.1,775 639,728.7 524.5,671.8 453.3,636.4 382.2,575.4 360.2,499 329.7,393 344.6,249.2 426,174.9 568.6,44.66 851.1,-8.71 1002,111.8 1091,182.7 1061,338.6 1041,450.4 Z;M 1066,436 C 1051,543.8 976.5,664.5 873.6,700.1 761,739.1 636.4,655.8 529.5,603.1 441.6,559.8 325.8,520.1 293.8,427.5 263.1,338.4 294.5,213.4 368.2,154.8 520.7,33.48 790.1,23.76 952.4,131.7 1043,191.7 1081,328.8 1066,436 Z;M 1066,436 C 1053,531.1 930.7,580.1 842.2,617.2 734,662.7 598.4,707.8 492.4,657.4 427.6,626.6 387.5,546.9 376.7,476 360.3,368.3 376.9,227.9 462.5,160.5 567.6,77.69 749.9,37.5 863.8,148.8 947.6,230.7 1082,320.1 1066,436 Z"/>
				</svg>
    </div>
                <div class="container titlecont">
           <h1 class="title"><a id="home"></a>PIGMENT</h1>
           <h2 class="subtitle">the history and science of color</h2>
       </div>    
    </div>
           
        <div class="blue">
            <div class="color-title blue">
                <h2><a id="blues"></a>THE BLUES</h2>
            </div>
            
            <div class="pigment-section cerulean">
                <div class="pigment-title cerulean">
                </div>
                
            </div>
    </div>
            
            
            
            
        <div class="green">
            <div class="color-title green">
                <h2><a id="greens"></a>THE GREENS</h2>
            </div>
            
            <div class="pigment-section verdigris">
                <div class="pigment-title verdigris">
                </div>
                
            </div>
            
        </div>   
    
    
    
        <div class="red">
            <div class="color-title red">
                <h2><a id="reds"></a>THE REDS</h2>
            </div>
            
            <div class="pigment-section crimson">
                <div class="pigment-title crimson">
                </div>
                
            </div>
        </div>    
            
            
        <div class="yellow">
            <div class="color-title yellow">
                <h2><a id="yellows"></a>THE YELLOWS</h2>
            </div>
            
            <div class="pigment-section chromeyell">
                <div class="pigment-title chromeyell">
                </div>
                
            </div>
        </div>  
            
            
        <div class="rest">
            <div class="color-title rest">
                <h2><a id="rest"></a>THE REST</h2>
            </div>
            
            <div class="pigment-section leadwhite">
                <div class="pigment-title leadwhite">
                </div>
                
            </div>
        </div>
        
        
<!-- jQuery and Bootstrap links - do not delete! -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<!-- end of do not delete -->
    <script src="js/anime.min.js"></script>
		<script src="js/demo.js"></script>
		<script src="js/demo4.js"></script>    
    

              
            
!

CSS

              
                @charset "UTF-8";
/* Add your custom CSS declarations below  */

@import url('https://fonts.googleapis.com/css?family=PT+Serif');
@import url('https://fonts.googleapis.com/css?family=Arapey');
@import url('https://fonts.googleapis.com/css?family=Oswald');



body {
    font-family: 'Oswald', sans-serif;
    background-color: #F05FD4;
}


.spacer {
    height: calc(61vw - 56px);
    max-height: calc(100vh - 56px);
}

h2 {
    text-align: center;
}

.scene path {
	fill: #0038FF;
}

.shapes {
    z-index: -99;
    position: absolute;
    width: 100vw;
}
/* ------------------Title------------------------------------------------*/

.title {
    color: white;
    font-family: "Oswald", sans-serif;
    font-size: 4rem;
    text-align: center;
    padding-top: 10vw;
    pointer-events: none;
    z-index: 1000;
}

    /* Small devices (landscape phones, 576px and up) */
    @media (min-width: 576px) { 
        .title {
            font-size: 6rem;
        }
    }

    /* Medium devices (tablets, 768px and up) */
    @media (min-width: 768px) { 
        .title {
            font-size: 8rem;
        }
    }

    /* Large devices (desktops, 992px and up) */
    @media (min-width: 992px) { 
        .title {
            font-size: 10rem
        }
    }

    /* Extra large devices (large desktops, 1200px and up) */
    @media (min-width: 1200px) { 
        .title {
            font-size: 12rem;
        }
    }

/* ------------------Subtitle------------------------------------------------*/

.subtitle {
    color: white;
    font-family: "Oswald", sans-serif;
    font-size: 1.15rem;
    text-align: center;
    padding-bottom: 15vw;
}

    /* Small devices (landscape phones, 576px and up) */
    @media (min-width: 576px) { 
        .subtitle {
            font-size: 1.75rem;
        }
    }

    /* Medium devices (tablets, 768px and up) */
    @media (min-width: 768px) { 
        .subtitle {
            font-size: 2.3rem;
        }
    }

    /* Large devices (desktops, 992px and up) */
    @media (min-width: 992px) { 
        .subtitle {
            font-size: 2.9rem
        }
    }

    /* Extra large devices (large desktops, 1200px and up) */
    @media (min-width: 1200px) { 
        .subtitle {
            font-size: 3.5rem;
        }
    }
/* ------------------Navigation------------------------------------------------*/

.navbar-light .navbar-toggler-icon {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.8)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}

.navbar-light .navbar-toggler {
  color: rgba(0, 0, 0, 0.8);
  border-color: rgba(0, 0, 0, 0.8);
}

.nav-item {
    color: rgba(0, 0, 0, 0.8);
}

.nav-link {
    color: rgba(0, 0, 0, 0.8);
}
/* ------------------Carousel------------------------------------------------*/

.carousel {
    z-index: -99;
    position: absolute; 
    width: 100%; 
    height: 100%;
}

img {
    width: 100vw;
}

.carousel-fade .carousel-item {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transition: opacity 900ms ease;
}
.carousel-fade .carousel-item.active {
  opacity: 1;
}

/* Fixed height, can be dynamic using JS */
.carousel-fade .carousel-inner,
.carousel-fade .carousel-item {
  height: 100vh;
}

/* -----------------------Elements-------------------------------------------*/

.color-title {
    
}

.pigment-section {
    
}

.pigment-title {
    
}

/* ---------------------------Blues---------------------------------------*/

.blue {
    background-color: cornflowerblue;
    height: 50vh;
}

.color-title.blue {
    
}

.pigment-section.cerulean {
    
}

.pigment-title.cerulean {
    
}

/* ---------------------------Greens---------------------------------------*/

.green {
    background-color: darkseagreen;
    height: 50vh;
}

.color-title.green {
    
}

.pigment-section.verdigris {
    
}

.pigment-title.verdigris {
    
}

/* ---------------------------Reds---------------------------------------*/

.red {
    background-color: palevioletred;
    height: 50vh;
}

.color-title.red {
    
}

.pigment-section.crimson {
    
}

.pigment-title.crimson {
    
}

/* ---------------------------Yellows---------------------------------------*/

.yellow {
    background-color: lightgoldenrodyellow;
    height: 50vh;
}

.color-title.yellow {
    
}

.pigment-section.chromeyell {
    
}

.pigment-title.chromeyell {
    
}

/* ---------------------------Rest---------------------------------------*/

.rest {
    background-color: lightslategray;
    height: 50vh;
}

.color-title.rest {
    
}

.pigment-section.leadwhite {
    
}

.pigment-title.leadwhite {
    
}
              
            
!

JS

              
                {
	// equation of a line
	const lineEq = (y2, y1, x2, x1, currentVal) => {
		// y = mx + b
		const m = (y2 - y1) / (x2 - x1);
		const b = y1 - m * x1;

		return m * currentVal + b;
	}

	// from http://www.quirksmode.org/js/events_properties.html#position
	const getMousePos = (e) => {
		let posx = 0;
		let posy = 0;
		if (!e) {let e = window.event};
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		return {
			x : posx,
			y : posy
		};
	};

	// From https://davidwalsh.name/javascript-debounce-function.
	function debounce(func, wait, immediate) {
		var timeout;
		return function() {
			var context = this, args = arguments;
			var later = function() {
				timeout = null;
				if (!immediate) func.apply(context, args);
			};
			var callNow = immediate && !timeout;
			clearTimeout(timeout);
			timeout = setTimeout(later, wait);
			if (callNow) func.apply(context, args);
		};
	};

	class MorphingBG {
		constructor(el) {
			this.DOM = {};
			this.DOM.el = el;
			this.DOM.el.style.opacity = 0;
			this.DOM.el.style.transition = 'transform 2s ease-out';
			this.DOM.pathEl = this.DOM.el.querySelector('path');
			this.paths = this.DOM.pathEl.getAttribute('pathdata:id').split(';')
			this.paths.splice(this.paths.length, 0, this.DOM.pathEl.getAttribute('d'));
			this.win = {width: window.innerWidth, height: window.innerHeight};
			this.animate();
			this.initEvents();
		}
		animate() {
			anime.remove(this.DOM.pathEl);
			anime({
				targets: this.DOM.pathEl,
				duration: 10000,
				easing: [0.5,0,0.5,1],
				d: this.paths,
				loop: true
			});
		}
		initEvents() {
			// Mousemove event / Tilt functionality.
			const tilt = {
				tx: this.win.width/8,
				ty: this.win.height/4,
				rz: 45,
				sx: [0.8,2],
				sy: [0.8,2]
			}
			const onMouseMoveFn = (ev) => {
				requestAnimationFrame(() => {
					if ( !this.started ) {
						this.started = true;
						anime({
							targets: this.DOM.el,
							duration: 300,
							easing: 'linear',
							opacity: [0,1]
						});
					}
					else {
						const mousepos = getMousePos(ev);					
						const rotZ = 2*tilt.rz/this.win.height*mousepos.y - tilt.rz;
						const scaleX = mousepos.x < this.win.width/2 ? lineEq(tilt.sx[0],tilt.sx[1],this.win.width/2,0,mousepos.x) : lineEq(tilt.sx[1],tilt.sx[0],this.win.width,this.win.width/2,mousepos.x);
						const scaleY = mousepos.y < this.win.height/2 ? lineEq(tilt.sy[0],tilt.sy[1],this.win.height/2,0,mousepos.y) : lineEq(tilt.sy[1],tilt.sy[0],this.win.height,this.win.height/2,mousepos.y);
						const transX = 2*tilt.tx/this.win.width*mousepos.x - tilt.tx;
						const transY = 2*tilt.ty/this.win.height*mousepos.y - tilt.ty;

						this.DOM.el.style.transform = `translate3d(${transX}px, ${transY}px,0) rotate3d(0,0,1,${rotZ}deg) scale3d(${scaleX},${scaleY},1)`;
					}
				});
			};

			// Window resize.
			const onResizeFn = debounce(() => this.win = {width: window.innerWidth, height: window.innerHeight}, 20);

			document.addEventListener('mousemove', onMouseMoveFn);
			document.addEventListener('touchstart', onMouseMoveFn);
			window.addEventListener('resize', ev => onResizeFn());
		}
	};

	new MorphingBG(document.querySelector('svg.scene'));
};
              
            
!
999px

Console