cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
	
<div class="clearfix wrap">
   	 
     <!--Column#1-->
   	 <div class="col col2">
          <div class="box box6"></div>
          <div class="box box4"></div>
          <div class="box box2"></div> 
     </div>
     
     <!--Column#2-->
     <div class="col col3">
     	<div class="box box2"></div>
        <div class="box box6"></div>        
        
        <div class="col col3">
            <div class="box box4"></div>
        </div>
        <div class="col col3">
            <div class="box box4"></div>
        </div>
        <div class="col col4">
            <div class="box box4"></div>
        </div>
     </div>
     
     <!--Column#3-->
     <div class="col col1">
     	<div class="box box4"></div>
        <div class="box box6">
        </div>
        <div class="box box2"></div>
     </div>
     
     <!--Column#4-->
     <div class="col col4">
     	<div class="col col5">
        	<div class="box box3"></div>
        	<div class="box box2"></div>
        </div>
        
        <div class="col col5">
        	<div class="box box2"></div>
        	<div class="box box3"></div>
        </div>
        
     	<div class="box box7"></div>
     </div>
</div> 
            
          
!
            
              /*CLEARFIX*/
.clearfix:after {content: ".";	display: block;	clear: both; visibility: hidden; line-height: 0; height: 0;} 
.clearfix {	display: inline-block;} 
html[xmlns] .clearfix {display: block;} 
* html .clearfix {height: 1%;}

/*CSS RESET*/
html,body,div,span,applet,object,iframe,
h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,
del,dfn,em,img,ins,kbd,q,s,samp,
small,strike,strong,sub,sup,tt,var,
b,u,i,center,
dl,dt,dd,ol,ul,li,
fieldset,form,label,legend,
table,caption,tbody,tfoot,thead,tr,th,td,
article,aside,canvas,details,embed,
figure,figcaption,footer,header,hgroup,
menu,nav,output,ruby,section,summary,
time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;}

/* HTML5 display-role reset for older browsers */
article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section{display:block;}
body{line-height:1;}
ol,ul{list-style:none;}
blockquote,q{quotes:none;}
blockquote:before,blockquote:after,
q:before,q:after{content:'';content:none;}
table{border-collapse:collapse;border-spacing:0;}

/*GLOBALS*/
a{text-decoration:none;	}
body, hmtl{background: #ccc; font-family: Arial, sans-serif;}

/*WRAPPER*/
.wrap{
	width:100%;		
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	
	padding:8px;		
}

/*COLUMNS*/
.col{
	float:left;		
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;	
	width:20%;
	padding:8px;	
}


.col1{width:10%;}
.col2{width:20%;}
.col3{width:30%;}
.col4{width:40%;}
.col5{width:50%;}
.col6{width:60%;}
.col7{width:70%;}
.col8{width:80%;}
.col9{width:90%;}
.col10{width:100%;}



/*SUB-COLUMN*/
.col .col{	padding:0; padding-left:0px;}
.col .col ~ .col{padding-left:16px;}

.col .col1{width:10%;}
.col .col2{width:20%;}
.col .col3{width:30%;}
.col .col4{width:40%;}
.col .col5{width:50%;}
.col .col6{width:60%;}
.col .col7{width:70%;}
.col .col8{width:80%;}
.col .col9{width:90%;}
.col .col10{width:100%;}


/*BOXES*/
.box{
	width:100%; 
	margin-bottom:12px; 
	background:#999; 
	clear:both;
	background-color: #eaeaea;
	box-shadow:rgba(0,0,0,0.3) 0px 0px 5px;
	border:5px solid #fff;
	
	background-position:center; 
	
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	
	text-align:center;
	color:#fff;	
	
	cursor:pointer;
	
	-webkit-transition: all 0.2s ease;
	-moz-transition:    all 0.2s ease;
	-o-transition:      all 0.2s ease;
	-ms-transition:     all 0.2s ease;
	transition:         all 0.2s ease;	
}

.box:hover{
	-moz-transform: scale(0.98);
	-webkit-transform: scale(0.98);
	-o-transform: scale(0.98);
	-ms-transform: scale(0.98);
	transform: scale(0.98);	
}


.box1{height:50px;}
.box2{height:100px;}
.box3{height:150px;}
.box4{height:200px;}
.box5{height:250px;}
.box6{height:300px;}
.box7{height:350px;}
.box8{height:400px;}
.box9{height:450px;}
.box10{height:500px;}


/*TEXT*/
h2, span{	padding:0 15px;	text-shadow:rgba(0,0,0,0.8) 0px 0px 3px;}
h2{	font-size:24px;	font-weight:bold; font-family: 'Kaushan Script', cursive; margin-bottom:4px;}
span{font-size:14px; }



/*OVERLAY*/
.overlay{
	position:fixed;
	background:rgba(0,0,0,0.8);
	z-index:100;
	top:0;
	left:0;
	width:100%;
	height:100%;	
}

.pop{
	position:absolute;
	top:50%;
	left:50%;
	width:400px;
	padding:20px;
	height:240px;
	margin:	-110px 0px 0px -220px;
	background:#fff;
	color:#666;
	overflow:hidden;
}

.pop span{	text-shadow:none;	color:#066;		padding:0;}
.pop h2{text-shadow:none; font-size:16px; color:#666; text-align:center;}
.pop h1{font-size:36px;  font-family: 'Kaushan Script', cursive; margin-bottom:4px; color:#666; margin-bottom:14px; text-align:center;}
.pop div{	margin-top:30px;}
.pop p{line-height:140%;}

#close{
	position:absolute;
	top: -17px;
	right: 15px;
	cursor:pointer;	
}

@media screen and (max-width: 1100px){
	.col1{width:20%;}
	.col2{width:40%;}
	.col3{width:60%;}
	.col4{width:80%;}
	.col5{width:100%;}
	.col6{width:120%;}
	.col7{width:140%;}
	.col8{width:160%;}
	.col9{width:180%;}
	.col10{width:200%;}
	
}

@media screen and (max-width: 678px){
	
	.col{width:100%;}	
	.col .col{	width:100%;	padding-left:0 !important ;	}
}



.pop h1, .pop h2{
	-webkit-transition: all 0.5s ease;
	-moz-transition:    all 0.5s ease;
	-o-transition:      all 0.5s ease;
	-ms-transition:     all 0.5s ease;
	transition:         all 0.5s ease;	
}


/*hide left*/
.pop h1{
	-moz-transform: translateX(-200px);
	-webkit-transform: translateX(-200px);
	-o-transform: translateX(-200px);
	-ms-transform: translateX(-200px);
	transform: translateX(-200px);
	opacity:0;
}

/*hide right*/
.pop h2{
	-moz-transform: translateX(200px);
	-webkit-transform: translateX(200px);
	-o-transform: translateX(200px);
	-ms-transform: translateX(200px);
	transform: translateX(200px);	
	opacity:0;
}

/*Slide left > right || right > left*/
.pop h1.animationActive, .pop h2.animationActive {
	-moz-transform: translateX(0px);
	-webkit-transform: translateX(0px);
	-o-transform: translateX(0px);
	-ms-transform: translateX(0px);
	transform: translateX(0px);	
	opacity:1;
}



            
          
!
            
              //NO JAVASCRIPT IS REALLY REQUIRED - THIS IS MOSTLY FOR ADDING THE COLORS AND IMAGES. THE GRID ITSELF IS DONE USING ONLY HTML AND CSS


$(document).ready(function(){
	
	
	 popup();
	
	 verticalText();
	
	//CREATE THE IMAGES
	$('.box-img').each(function(){
		var t = $(this);
		createImg(t);
	});	
	
	
	//RE-GENERATE IMAGES WHEN WINDOW RESIZED
	$(window).resize(function() {
		$('.box-img').each(function(){
			var t = $(this);
			createImg(t);
		});	
	});
	
	

	
	//ADD A COLOR BOX OR IMAGE BOX
	document.oncontextmenu = function() {return false;};
	
	$('.box').mousedown(function(e){ 
		
		var t = $(this);		
		var h2 = $(this).find('h2');
			
		if(h2.length){			
		}else{
			var h2t = document.createElement('h2');
			this.appendChild(h2t);
			
			var span = document.createElement('span');
			span.innerHTML = "This is a description of the box";
			this.appendChild(span);
		}
		
		//LEFT CLICK ADD IMG
		if( e.button == 0 ) { 
			$(this).addClass('box-img');
			$(this).find('h2').text("This is an image box");
			createImg(t);			
		}
		
		//RIGHT CLICK ADD COLOR
		if( e.button == 2 ) {
		   $(this).find('h2').text("This is a color box");
		   $(this).css('background-color', getRandomColor());
		   t.removeClass('box-img');
		   t.css('background-image', ''); 		  
		}
		
		verticalText();	
				
		
	}); 
	

});//DOCUMENT READY
	


function createImg(t){
	//get ths size of the box
	var w = t.width();
	var h = t.height();
	
	//make the image to be the same size of the box
	var src = "url(http://lorempixel.com/" + w + "/" + h + ")";
	
	t.css('background-image', src); 	
}



function verticalText(){
	//vertically center the text
	$('.box').each(function(){
		
		//let's vertically center the text
		var h2 = $(this).find('h2');
		
		if(h2.length){
			//found a <h2> tag
			var boxHeight = $(this).height()/2;
			var textHeight = h2.height()/2;
			var spanHeight = $(this).find('span').height()/2;
			
			var height = boxHeight - textHeight - spanHeight - 2; 
			
			h2.css('margin-top', height + 'px');
			
		}else{
			//didnt find a <h2>
		}		
		
	});
		
}



function getRandomColor() {
    var letters = '0123456789ABCDEF'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++ ) {
        color += letters[Math.floor(Math.random() * 16)];
    }
    return color;
}




function popup(){
	var overlay = $('<div class="overlay"></div>');
	overlay.appendTo($('body'));
	
	var box = $('<div class="pop"></div>').appendTo(overlay);
	
	var title = "<h1>Custom Grid Layout</h1>   <h2>A Pen by <a href='http://www.andrecortellini.com' target='_blank'><span>André Cortellini</span></a></h2>";
	
	var text = "<div><p>- Left click to add an image box</p> <p>- Right click to add a color box</p></div>";	
	var text2 = "<div><p>Create your custom gallery layout using this simple and responsive grid system</p></div>";
	
	box.html(title + text + text2);
	
	var clos = $('<div id="close">x</div>').appendTo(box);
	
	
	/******************************
	 ADD ANIMATION TO THE TEXT 
	******************************/
	var count = 0;
	var number = 10;
	
	var interval = setInterval(function(){
       count++;
	   if (count === number) { 
	   		clearInterval(interval);
			$('.pop h1 ,.pop h2').addClass('animationActive');		
		}
	}, 50);
	
	
	clos.click(function(){
		$(this).parent().parent().remove();
	});
	
}

























	

            
          
!
999px
Loading ..................

Console