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

              
                	<body>

		<div class="marquee">
			<div class="marquee_data">
				<div class="marquee_panel" data-image="assets/images/photo_beach">
					<h3>Secluded beaches</h3>
					<p>Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
					<a class="cta" href="http://lynda.com">Learn more</a>
					
				</div>
				<div class="marquee_panel" data-image="assets/images/photo_city">
					<h3>Beautiful cityscape</h3>
					<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
					<a class="cta" href="http://lynda.com">Learn more</a>
				</div>
				<div class="marquee_panel" data-image="assets/images/photo_mountains">
					<h3>Magestic mountain peaks</h3>
					<p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia.</p>

					<a class="cta" href="http://lynda.com">Learn more</a>
				</div>
				
			</div>
		</div>
		<div style="margin-top:50px;">
			<div class="var1">x</div>
			<div class="var2">x</div>
			<div class="var3">x</div>
			<div class="var4">x</div>
			<div class="var5">x</div>
			<div class="var6">x</div>
			<div class="var7">x</div>
			<div class="var8">x</div>
			<div class="var9">x</div>
		</div>
		
		

	</body>
</html>
              
            
!

CSS

              
                /* CSS Document */
@import url(https://fonts.googleapis.com/css?family=Lato:300|PT+Serif:400);

body {  margin: 0px; padding: 10px; }

.marquee { font-size: 16px; height: 425px; max-width: 1200px; margin: 0px auto 20px auto; border: 1px solid #000; }

.marquee .marquee_data { display: none; }

.marquee .marquee_stage_large { height: inherit; position: relative; overflow: hidden; }

.marquee .marquee_container_1,
.marquee .marquee_container_2 { height: inherit; position: absolute: top: 0px; left: 0px; width: 100%; }
.marquee .marquee_container_1 { z-index: 101; }
.marquee .marquee_container_1 { z-index: 102; }

.marquee .marquee_panel { height: inherit; width: 100%; 
	position: absolute; top: 0px; left: 0px; 
	text-align: center; 
	background-repeat: no-repeat;
	background-position: center 0px;
	background-size: cover;

}

.marquee .marquee_panel .panel_caption {
	width: 68%;
	position: absolute; bottom: 35px; left: 0px;
	margin-left: 16%;
	font-family: 'Lato', sans-serif;
	padding-bottom: 15px;
	/*border: 1px solid #fff;*/
}

.marquee .marquee_panel .panel_caption h3 { font-family: 'PT Serif', serif; margin: 0px 0px 0px 0px; font-weight: 400; font-size: 2.7em; color:#fff; }
.marquee .marquee_panel .panel_caption p { margin: 0px 50px 15px 50px; color: #888; font-size: 1.3em; color: rgba(255,255,255,.75); }
.marquee .marquee_panel .panel_caption a.cta { display: inline-block; background-color: rgba(255,255,255,0); text-transform: uppercase; color:#fff; font-size: .9em; padding: 6px 20px; transition: background-color .7s, border .7s; border: 1px solid rgba(255,255,255,.5); border-radius: 5px; text-decoration: none; }

.marquee .marquee_panel .panel_caption a:hover { background-color: rgba(255,255,255,.6); color:#000; border-color: rgba(255,255,255,0); }

.marquee .overlay { 
	position: absolute; left: 0px; top: 0px;
	width: 100%; height: 100%;
	background-image: linear-gradient(rgba(0,0,0,0)45%, rgba(0,0,0,.7)70%);
	background-size:  !00%;
}

.marquee .marquee_nav {
	position: absolute; bottom: 10px; left: 0px;
	text-align: center; width: 100%;
	z-index: 103;
}

.marquee .marquee_nav div {
	display: inline-block;
	width: 10px; height: 10px;
	border: 2px solid rgba(255,255,255,.5);
	border-radius: 50%;
	margin: 0px 8px 0px 8px;
	cursor: pointer;
	transition: background-color .4s, border .4s;
}

.marquee .marquee_nav div:hover { border-color: #fff; background-color: rgba(255,255,255,.2); }

.marquee .marquee_nav div.selected { background-color: #fff; }

.marquee .btn {
	width: 39px; height: 39px;
	background: rgba(255,255,255,.2) no-repeat;
	background-size: 50px 30px;
	position: absolute; top: 192px;
	cursor: pointer;
	border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
	transition: background-color .4s, border .4s;
}

.marquee .btn:hover { border-color: #fff; background-color: rgba(0,0,0,.6); }
.marquee .btn.prev {
	left: 20px; z-index: 104;
	background-image: url(../images/arrow_left.svg); background-position: -8px 4px;
}
.marquee .btn.next {
	right: 20px; z-index: 105;
	background-image: url(../images/arrow_right.svg); background-position: -3px 4px;
}

.marquee .marquee_stage_small {
	height: inherit; position: relative; overflow: hidden;
	
}

.marquee .marquee_stage_small .marquee_panel {
	width: 100%; height: inherit;
	position: absolute; top: 0px; left: 0px;
}


@media screen and (max-width: 800px) {
	
	.marquee { font-size: 14px; height: 325px; background-color: #444 }
	.marquee btn { 
		width: 29px; height: 29px;
		background-size: 33px 20px; top: 140px;
	}
	.marquee .btn.prev { background-position: -4px 4px; }
	.marquee .btn.next { background-position: -1px 4px; }
	.marquee .marquee_panel .panel_caption { width: 80%; margin-left: 10%; }
	.marquee .marquee_panel .panel_caption p { display: none; }
	.marquee .marquee_panel .panel_caption a.cta { margin-top: 10px; padding: 4px 20px; }
	.marquee .marquee_nav div {
		width: 13px; height: 13px;
		margin: 0px 12px 0px 12px;
	}
}

@media screen and (max-width: 600px) {
	.marquee { height; 250px; }
	.marquee .overlay { dispaly: none; }
	.marquee .marquee_panel .panel_caption {
		margin: 0px; padding: 10px 10px 20px 10px;
		width: 100%; bottom: 0px; background-color: rgba(0,0,0,.65);
	}
	.marquee .marquee_panel .panel_caption a.cta { padding: 8px 30px; }
}



              
            
!

JS

              
                /* JavaScript Document */

var marqueeVars = {
	screenSize : '',
	width : 0,
	mobileSize : 600,
	autoPlay : true,
	currentPanel : 1,
	totalPanels : 0,
	timePassed : 0,
	timeToChange : 30,
	duration : 1250,
	inTransition : false,
	panelContent : Array
	
};

$(document).ready(function(){
	marqueeGatherData();
	
});

function marqueeGatherData(){
	$('.marquee_data .marquee_panel').each(function(index){
		marqueeVars.totalPanels = index + 1;
		var panel_image_l = $(this).attr('data-image')+'_l.jpg';
		var panel_image_s = $(this).attr('data-image')+'_s.jpg';
		var panel_caption = $(this).html();
		marqueeVars.panelContent[index] = '<div class="marquee_panel" data-image-s="'+panel_image_s+'" style="background-image: url('+panel_image_l+');"><div class="overlay"></div><div class= "panel_caption">'+panel_caption+'</div></div>';
		//alert(panel_image_s);
	});
	var marqueeTimer = setInterval(marqueeAdvance, 100);
}

function marqueeAdvance(){
	var marqueeWidth = $('.marquee').width();
	var currentSize = marqueeVars.screenSize;
	if( marqueeWidth > marqueeVars.mobileSize ){
		var newSize = 'large';
	} else {
		var newSize = 'small';
	}
	marqueeVars.screenSize = newSize;
	
	if( currentSize != newSize ){
		if( marqueeVars.screenSize == 'large' ){
			marqueeMultiPanel();
		} else {
			marqueeSinglePanel();
		}
	}
	
	if( marqueeVars.timePassed == marqueeVars.timeToChange ){
		marqueeVars.timePassed = 0;
		
		if( marqueeVars.autoPlay == true ){
			if( marqueeVars.currentPanel == marqueeVars.totalPanels ){
				$('.marquee_nav div:nth-child(1)').trigger('click');
			} else {
				$('.marquee_nav div:nth-child('+(marqueeVars.currentPanel+1)+')').trigger('click');
			}
		}
		
		
	} else {
		marqueeVars.timePassed += 1;
	}
}

function marqueeMultiPanel(){
	marqueeVars.timePassed = 0;
	marqueeVars.autoPlay = true;
	var newHTML = '<div class="marquee_stage_large"><div class="marquee_container_1"></div><div class="marquee_nav"></div><div class="btn prev"></div><div class="btn next"></div></div>';
	$('.marquee').html('').append(newHTML);
	
	for( i=0; i<marqueeVars.totalPanels; i++ ){
		$('.marquee_nav').append('<div></div>');
	}
	
	$('.marquee').hover(function(){
		marqueeVars.autoPlay = false;
	},function(){
		marqueeVars.autoPlay = true;
		marqueeVars.timePassed = Math.floor(marqueeVars.timeToChange / 2);
		
	});
	
	$('.marquee .btn').on('click', function(){
		
		if( !marqueeVars.inTransition ){
			
			if( $(this).hasClass('prev') ){
				marqueeVars.currentPanel -= 1;
				if( marqueeVars.currentPanel < 1 ){
					marqueeVars.currentPanel = marqueeVars.totalPanels;
				}
			} else {
				marqueeVars.currentPanel += 1;
				if( marqueeVars.currentPanel > marqueeVars.totalPanels ){
					marqueeVars.currentPanel = 1;
				}
				
			}
			
			$('.marquee_nav div:nth-child('+marqueeVars.currentPanel+')').trigger('click');
			
		}
	});
	
	$('.marquee_nav div').on('click', function(){
		
		if( !marqueeVars.inTransition ){
			
			marqueeVars.inTransition = true;
			
			var navClicked = $(this).index();
			marqueeVars.currentPanel = navClicked + 1;
			
			$('.marquee_nav div').removeClass('selected');
			$(this).addClass('selected');
			
			$('.marquee_stage_large').append('<div class="marquee_container_2" style="opacity:0;"></div>');
			$('.marquee_container_1').remove();
			$('.marquee_container_2').html(marqueeVars.panelContent[navClicked]).animate({opacity:1},marqueeVars.duration,function(){
				$('.marquee_container_1').remove();
				$(this).addClass('marquee_container_1').removeClass('marquee_container_2');
				marqueeVars.inTransition = false;
			});
		}
		
	});
	
	//$('.marquee_nav div:first').trigger('click');
}

function marqueeSinglePanel(){
	$('.marquee').html('').append('<div class="marquee_stage_small">'+marqueeVars.panelContent[0]+'</div>');
	var panel_image_s = $('.marquee .marquee_stage_small .marquee_panel').attr('data-image-s');
	$('.marquee .marquee_stage_small .marquee_panel').css('background-image', 'url('+panel_image_s+')');
}


//debugger
var debugTimer = setInterval(setDebugger,100);
function setDebugger(){
	$('.var1').html('screenSize = '+marqueeVars.screenSize);
	$('.var2').html('width = '+marqueeVars.width);
	$('.var3').html('mobileSize = '+marqueeVars.mobileSize);
	$('.var4').html('autoPlay = '+marqueeVars.autoPlay);
	$('.var5').html('currentPanel = '+marqueeVars.currentPanel);
	$('.var6').html('totalPanels = '+marqueeVars.totalPanels);
	$('.var7').html('timePassed = '+marqueeVars.timePassed);
	$('.var8').html('timeToChange = '+marqueeVars.timeToChange);
	$('.var9').html('inTransition = '+marqueeVars.inTransition); 
}


              
            
!
999px

Console