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

              
                <div class="top-container">
  <h1>Scroll Down</h1>
  <p>Scroll down 👇 to animate the rose 🌹</p>
</div>

<div class="header" id="myHeader">
  <h2>A 🌹 by any other name</h2>
	<div id="sketch-holder"></div>
</div>

<div class="content">
	<br><br><br>
	<h2>Juliet:</h2>

	<p>O Romeo, Romeo! wherefore art thou Romeo?</p>
	<p>Deny thy father and refuse thy name;</p>
	<p>Or, if thou wilt not, be but sworn my love,</p>
	<p>And I'll no longer be a Capulet</p>
<br><br><br>
	<h2>Romeo:</h2>

	<p>[Aside] Shall I hear more, or shall I speak at this?</p>
<br><br><br>
	<h2>Juliet:</h2>

<p>'Tis but thy name that is my enemy;</p>
<p>Thou art thyself, though not a Montague.</p>
<p>What's Montague? It is nor hand, nor foot,</p>
<p>Nor arm, nor face, nor any other part</p>
<p>Belonging to a man. O, be some other name!</p>
<p>What's in a name? That which we call a rose</p>
<p>By any other name would smell as sweet;</p>
<p>So Romeo would, were he not Romeo call'd,</p>
<p>Retain that dear perfection which he owes</p>
<p>Without that title. Romeo, doff thy name,</p>
<p>And for that name which is no part of thee</p>
<p>Take all myself.</p>
<br><br><br>
	<h2>Romeo:</h2>

<p>I take thee at thy word:</p>
<p>Call me but love, and I'll be new baptized;</p>
<p>Henceforth I never will be Romeo.</p>
	<br><br><br><br><br><br><br><br><br>
</div>
              
            
!

CSS

              
                body{
	margin:0 auto;
	overflow-x:hidden;
	background-color:rgba(240,58,23,0.2);
	font-family:"Trebuchet MS", Helvetica, sans-serif;
}
#sketch-holder{
	position:relative;
	left:calc(100% - 100px);
	top:-70px;
	transition:left 1200ms;
}
.top-container {
  background-color: rgb(19,117,150);
  padding: 30px;
  text-align: center;
}

.header {
  padding: 10px 10px 10px;
	height:80px;
  background: rgb(3,71,94);
  color: #f1f1f1;
}

.content {
  padding: 16px;
}

.sticky {
  position: fixed;
  top: 0;
  width: 100%;
}

.sticky + .content {
  padding-top: 102px;
}
              
            
!

JS

              
                // Maurer Rose
// Inspired by Dan Shiffman of The Coding Train
// https://youtu.be/4uU9lZ-HSqA
// https://en.wikipedia.org/wiki/Maurer_rose

let n = 200;
let d = 290;
//more is less flower movement
let noisy = 5;

function setup(){
	var cnvs = createCanvas(80,80);
	cnvs.parent('sketch-holder');
	
  angleMode(DEGREES);
}

function draw() {
  background(3,71,94);
  translate(width/2,height/2);
  stroke(255);
  
	d = (Math.ceil(window.scrollY/noisy)*noisy)/noisy;
	n = (Math.ceil(window.scrollY/noisy)*noisy)/noisy;
	
  noFill();
  beginShape();
  strokeWeight(0.5);
  for (let i = 0; i < 361; i++) {
    let k = i * d;
    let r = 40 * sin(n*k);
    let x = r * cos(k);
    let y = r * sin(k);
    vertex(x,y);    
  }
  endShape();

  noFill();
  stroke(240,58,23, 255);
  strokeWeight(0.3);
  beginShape();
  for (let i = 0; i < 361; i++) {
    let k = i;
    let r = 40 * sin(n*k);
    let x = r * cos(k);
    let y = r * sin(k);
    vertex(x,y);    
  }
  endShape();
  
}

window.onscroll = function() {myFunction()};

var header = document.getElementById("myHeader");
var sticky = header.offsetTop;

function myFunction() {
  if (window.pageYOffset > sticky) {
    header.classList.add("sticky");
  } else {
    header.classList.remove("sticky");
  }
}
              
            
!
999px

Console