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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <!-- update 'src' audio file links here with your own! -->

<div id="background1"><audio id="audioTag1" src="https://austinfranklin.github.io/7746MediaRepo/media/birds.mp3">
</div>

<div id="background2"><audio id="audioTag2" src="https://austinfranklin.github.io/7746MediaRepo/media/birds.mp3"></div>

<div id="background3"><audio id="audioTag3" src="https://austinfranklin.github.io/7746MediaRepo/media/birds.mp3"></div>

<div id="background4"><audio id="audioTag4" src="https://austinfranklin.github.io/7746MediaRepo/media/birds.mp3"></div>
              
            
!

CSS

              
                body {
	background-color: grey;
}

#backgroundPhoto {
	width: 100%;
	height: auto;
}

#background1 {
	width: 250px;
	height: 250px;
	background-color: darkgreen;
	position: absolute;
	top: 40%;
	left: 40%;
}

#background2 {
	width: 200px;
	height: 200px;
	background-color: darkgreen;
	position: absolute;
	top: 35%;
	left: 40%;
}

#background3 {
	width: 250px;
	height: 250px;
	background-color: darkgreen;
	position: absolute;
	top: 40%;
	left: 40%;
}

#background4 {
	width: 250px;
	height: 250px;
	background-color: darkgreen;
	position: absolute;
	top: 40%;
	left: 40%;
}

              
            
!

JS

              
                //image 1
function randomImage1() {
	var fileNames = [
		// change the images here!
		"https://dylanburchett.github.io/7746-Repo/media/photos/1.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/2.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/3.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/4.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/5.jpg"
	];
	var randomIndex = Math.floor(Math.random() * fileNames.length);
	document.getElementById("background1").style.background =
		"url(" + fileNames[randomIndex] + ")";
	randomizePosition();

	var audio = document.getElementById("audioTag1");
	audio.currentTime = 0;
	audio.playbackRate = Math.floor(Math.random() * 5);
	audio.volume = 0;
	audio.play();

	setTimeout(function () {
		if (audio.currentTime > 2) {
			audio.pause();
		}
	}, doSomething());
	setTimeout(randomImage1, randomSpeed());
}

//image 2
function randomImage2() {
	var fileNames = [
		// change the images here!
		"https://dylanburchett.github.io/7746-Repo/media/photos/1.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/2.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/3.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/4.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/5.jpg"
	];
	var randomIndex = Math.floor(Math.random() * fileNames.length);
	document.getElementById("background2").style.background =
		"url(" + fileNames[randomIndex] + ")";
	randomizePosition();

	var audio = document.getElementById("audioTag2");
	audio.currentTime = 0;
	audio.playbackRate = Math.floor(Math.random() * 5);
	audio.volume = 0;
	audio.play();

	setTimeout(function () {
		if (audio.currentTime > 4) {
			audio.pause();
		}
	}, doSomething());
	setTimeout(randomImage2, randomSpeed());
}

//image 3
function randomImage3() {
	var fileNames = [
		// change the images here!
		"https://dylanburchett.github.io/7746-Repo/media/photos/1.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/2.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/3.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/4.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/5.jpg"
	];
	var randomIndex = Math.floor(Math.random() * fileNames.length);
	document.getElementById("background3").style.background =
		"url(" + fileNames[randomIndex] + ")";
	randomizePosition();

	var audio = document.getElementById("audioTag3");
	audio.currentTime = 0;
	audio.playbackRate = Math.floor(Math.random() * 5);
	audio.volume = 0;
	audio.play();

	setTimeout(function () {
		if (audio.currentTime > 4) {
			audio.pause();
		}
	}, doSomething());
	setTimeout(randomImage3, randomSpeed());
}

//image 4
function randomImage4() {
	var fileNames = [
		// change the images here!
		"https://dylanburchett.github.io/7746-Repo/media/photos/1.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/2.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/3.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/4.jpg",
		"https://dylanburchett.github.io/7746-Repo/media/photos/5.jpg"
	];
	var randomIndex = Math.floor(Math.random() * fileNames.length);
	document.getElementById("background4").style.background =
		"url(" + fileNames[randomIndex] + ")";
	randomizePosition();

	var audio = document.getElementById("audioTag4");
	audio.currentTime = 0;
	audio.playbackRate = Math.floor(Math.random() * 5);
	audio.volume = 0;
	audio.play();

	setTimeout(function () {
		if (audio.currentTime > 4) {
			audio.pause();
		}
	}, doSomething());
	setTimeout(randomImage4, randomSpeed());
}

function doSomething() {}

//loop
/*
function loop() {
	var rand = Math.round(Math.random() * 1000);
	setTimeout(function () {
		doSomething();
		randomizePosition();
		loop();
	}, rand);
}
*/

//random parameters
function randomizePosition() {
	let a = Math.random() * 50 + 25;
	let b = Math.random() * 50 + 25;
	let c = Math.random() * 50 + 25;
	let d = Math.random() * 50 + 25;
	let e = Math.random() * 70 + 50;
	let f = Math.random() * 70 + 50;
	let g = Math.random() * 70 + 50;
	let h = Math.random() * 70 + 50;
	background1.style.top = `${a}%`;
	background1.style.left = `${b}%`;
	background2.style.top = `${c}%`;
	background2.style.left = `${d}%`;
	background1.style.width = `${e}px`;
	background1.style.height = `${f}px`;
	background2.style.width = `${g}px`;
	background2.style.height = `${h}px`;
	let i = Math.random() * 50 + 25;
	let j = Math.random() * 50 + 25;
	let k = Math.random() * 50 + 25;
	let l = Math.random() * 50 + 25;
	let m = Math.random() * 70 + 50;
	let n = Math.random() * 70 + 50;
	let o = Math.random() * 70 + 50;
	let p = Math.random() * 70 + 50;
	background3.style.top = `${i}%`;
	background3.style.left = `${j}%`;
	background4.style.top = `${k}%`;
	background4.style.left = `${l}%`;
	background3.style.width = `${m}px`;
	background3.style.height = `${n}px`;
	background4.style.width = `${o}px`;
	background4.style.height = `${p}px`;
}

function randomSpeed() {
	let rand = Math.random() * 1000;
	if (rand > 750) {
		return rand * 3;
	} else {
		return rand * Math.random();
	}
}

//function initialization
randomImage1();
setTimeout(randomImage1, randomSpeed());

randomImage2();
setTimeout(randomImage2, randomSpeed());

randomImage3();
setTimeout(randomImage3, randomSpeed());

randomImage4();
setTimeout(randomImage4, randomSpeed());

              
            
!
999px

Console