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

              
                <main class="type--1">
	<div class="wrap">
		<section class="mast">
			<h1 class="mast__title">Nutrition Facts</h1>
			<dl class="mast__list">
				<div class="serving">
					<dt>
						per container
					</dt>
					<dd>
						<span>8</span>
						<span>servings</span>
					</dd>
				</div>
				<div class="size">
					<dt>Serving size</dt>
					<dd>2/3 cup (55g)</dd>
				</div>
				<div class="calories">
					<div>
						<dt><span>Amount</span> per serving</dt>
						<dd class="calories__label">Calories</dd>
					</div>
					<dd class="calories__value">230</dd>
				</div>
			</dl>
		</section>
		<section class="values">
			<div class="values--a">
				<div class="values__title">
					<span>Amount/Serving</span>
					<span>% Daily Value</span>
				</div>
				<dl class="values__list">
					<div>
						<dt>Total Fat</dt>
						<dd>8g</dd>
						<dd>10%</dd>
					</div>
					<dl>
						<div>
							<dt>Saturated Fat</dt>
							<dd>1g</dd>
							<dd>5%</dd>						
						</div>
						<div>
							<dt><em>Trans</em> Fat</dt>
							<dd>0g</dd>
						</div>
					</dl>
					<div>
						<dt>Cholesterol</dt>
						<dd>0mg</dd>
						<dd>0%</dd>
					</div>
					<div>
						<dt>Sodium</dt>
						<dd>160mg</dd>
						<dd>7%</dd>
					</div>
				</dl>
			</div>
			<div class="values--b">
				<div class="values__title">
					<span>Amount/Serving</span>
					<span>% Daily Value</span>
				</div>
				<dl class="values__list">
					<div>
						<dt>Total Carbohydrate</dt>
						<dd>37g</dd>
						<dd>13%</dd>
					</div>
					<dl>
						<div>
							<dt>Dietary Fiber</dt>
							<dd>4g</dd>
							<dd>14%</dd>						
						</div>
						<div>
							<dt>Total Sugars</dt>
							<dd>12g</dd>
						</div>
						<dl>
							<div>
								<dt>Incl.</dt>
								<dd>10g Added Sugar</dd>
								<dd>20%</dd>
							</div>
						</dl>
					</dl>
					<div>
						<dt>Protein</dt>
						<dd>3g</dd>
					</div>
				</dl>
			</div>
			<div class="values--c">
				<dl class="values__list">
					<div>
						<dt>Vitamin D</dt>
						<dd>2mcg</dd>
						<dd>10%</dd>
					</div>
					<div>
						<dt>Calcium</dt>
						<dd>260mg</dd>
						<dd>20%</dd>
					</div>
					<div>
						<dt>Iron</dt>
						<dd>8mg</dd>
						<dd>45%</dd>
					</div>
					<div>
						<dt>Potassium</dt>
						<dd>240mg</dd>
						<dd>6%</dd>
					</div>
				</dl>
			</div>
		</section>
		<section class="footnote">
		<p>* The % Daily Value (DV) tells you how much a nutrient in a serving of food contributes to a daily diet. 2,000 calories a day is used for
			general nutrition advice.</p>
	</section>
	</div>
</main>

<!-- <form>
	<label><input type="radio" name="type" value="type-1"/>Type 1</label>
	<label><input type="radio" name="type" value="type-2"/>Type 2</label>
	<label><input type="radio" name="type" value="type-3"/>Type 3</label>
</form> -->
              
            
!

CSS

              
                //Outer styling rules
html {
		font-size:62.5%;
}
body {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	margin: 0;
	line-height: 1;
	font-family: Nunito, Helvetica, Arial, sans-serif;
  background: radial-gradient(ellipse at center, #F0F958 0%,#A0D346 100%); 
	font-size: 1.4rem;
	box-sizing: border-box;
}

// Type 1 - Standard Vertical Display
main {
	background: #fff;
	padding: 5px;
	width: 260px;
	height: 570px;
	overflow: hidden;
	box-shadow: 0px 2px 5px 0px rgba(0,0,0,.3);
	transition: height 300ms ease-out, width 300ms ease-out;
	.wrap {
		display: flex;
		flex-direction: column;	
	}
}
section {
	display: flex;
	flex-direction: column;
}

//Common List Styling Rules
dl {
	display: flex;
	flex-direction: column;
	flex-wrap: wrap;
	line-height: 1;
	margin: 0;
	> div {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		padding: 5px 0px;
	}
	dl dt{
		padding-left: 20px;
	}
	dl dl {
		margin-left: 40px;
	}
	dl dl dt {
		padding-left: 0px;
	}
	dd{
		display: flex;
		margin: 0;
	}
	dd,dt {
		margin-right: 3px;
	}
}

.mast{
	&__title{
		font-size: 3.6rem;
		font-weight: 900;
		margin: 0;
		border-bottom: 1px solid;
	}
	&__list{
		font-size: 1.7rem;
		line-height: 1;
	}
}

.serving {
	padding-bottom: 0px;
	dt{
		order: 2;
	}
	span{
		margin-right: 3px;
	}
}

.size {
	border-bottom: 10px solid;
	font-weight: 900;
	dt {
		flex: 1;
	}
}

.calories {
	border-bottom: 5px solid;	
	font-weight: 900;
	flex-direction: row;
	align-items: flex-end;
	padding: 5px 0px 2px 0px;
	div {
		flex: 1;
	}
	dt {
		font-size: 1.1rem;
		flex: 1 0 100%;
	}
	&__label{
		font-size: 3rem;
		flex: 1;
	}
	&__value{
		font-size: 3.6rem;
	}
}

.values{
	&__title {
		display: flex;
		font-size: 1.1rem;
		font-weight: 900;
		padding: 5px 0px;
		span:first-of-type{
			flex: 1;
			visibility: hidden;
		}
	}
	&__list {
		div {
			border-top: 1px solid;
		}
		dt {
			font-weight: 900;
		}
		dl dt {
			font-weight: 400;
		}
		dt+dd{
			flex: 1;
			+ dd{
				font-weight: 900;
			}
		}
	}
}

.values--b{
	.values__title{
		display: none;
	}
	.values__list {
		border-bottom: 10px solid;
	}
}
.values--c {
	.values__list {
		border-bottom: 5px solid;
		dt, dd {
			font-weight: 400;
		}
	}
}

.footnote {
	flex: 1 0;
	p {
		font-size: .9rem;
		margin: 0;
		padding: 5px 0px;
	}
}


// Type 2 - Tabular Display for Small to Medium Packages
main.type--2 {
	width: 610px;
	height: 180px;
	.wrap {
			display: grid;
			grid-template-columns: 140px 1fr;
			grid-column-gap: 10px;
	}
	.mast{
		&__title{
			font-size: 2.8rem;
		}
	}
	.size {
		border-bottom: 1px solid;
	}
	
	.calories {
		border-bottom: 0px;
		flex-diretion: row;
		>div {
			display: flex;
			flex-direction: column;
			line-height: .8;
		}
		&__label {
			order: 1;
			font-size: 2rem;
		}
		dt {
			order: 2;
			font-size: 1.4rem;
			span {
				display: none;
			}
		}
		&__value {
			order: 3;
			font-size: 2.8rem;
			margin-left: 5px;
		}
	}
	.values{
		display: grid;
		grid-template-columns: repeat(2,225px);
		grid-column-gap: 10px;
		grid-row-gap: 3px;
		flex-direction:row;
		flex-wrap: wrap;
		&--a,
		&--b {
			.values__list {
				border-bottom: 5px solid;	
			}
		}
		&--b {
			.values__title{
				display: flex;
			}
		}
		&--c {
			grid-column-start: 1;
	    grid-column-end: span 2;
			.values__list {
				flex-direction: row;
				border-bottom: 0px;
			}
			div {
				border-top: 0px;
				dd:first-of-type{
					display: none;
				}
				&:not(:last-child)::after {
					content: "•";
					font-size: .5em;
					margin-right: 4px;
				}
			}
		}
	}
	.values__title {
		border-bottom: 5px solid;
		span:first-of-type {
			visibility: visible;
		}
	}
	.footnote{
		display: none;
	}
}

// Type 2 - Linear Display for Small Packages
main.type--3 {
	width: 400px;
	height: 100px;
	.wrap{
		display: block;	
		font-size: 1.2rem;
	}
	section {
		display: contents;
	}
	dl {
		display: contents;
		float: left;
		margin-left: 0;
		line-height: 1.1;
		> div {
			display: contents;
			float: left;
			padding: 1px 0px;
		}
		dd, dt{
			display: contents;
			float: left;
		}
		dl dt {
			padding-left: 2px;
		}
	}
	.mast {
		&__title{
			width: auto;
			font-size: 1.8rem;
			display: contents;
			float: left;
			border-bottom: 0px;
		}
		&__list {
			font-size: 1.4rem;
		}
		.serving {
			margin-left: 140px;
			dt {
				display: none;
			}
		}
		.size {
			border-bottom: 0px
		}
		.calories {
			border-bottom: 0px;
			div {
				display: contents;
				float: left;
			}
			dt {
				font-size: 1.1rem;
				font-weight: 400;
			}
			&__label{
				font-size: 1.3rem;
				flex: 1;
			}
			&__value{
				font-size: 1.8rem;
			}
		}
	}
	.values {
		&--a,
		&--b,
		&--c{
			display: contents;
		}
		&__title {
			display: none;
		}
		&__list {
			border-bottom: 0px;
			div {
				border-top: 0px;
			}
			dt + dd + dd {
				font-weight: 400;
				&::before {
					content: "(";
				}
				&::after {
					content: " DV),";
				}
			}
		}
	}
	.footnote{
		display: none;
	}
}
              
            
!

JS

              
                $(function(){
    var timer, i=1;
    timer = setInterval(function(){
        if (i > 3) i = 1;
        $("main").removeClass().addClass("type--"+i);
        i++;
    }, 1600);
});

//$('input[type=radio]').change(function() {     
// 		if($(this).val() == "type-1"){   
// 	    $("main").removeClass().width();
// 			$('main').addClass('type--1');
//     }
//     else if($(this).val() == "type-2"){
// 			$("main").removeClass().width();
// 			$('main').addClass('type--2');
//     }
// 		else if($(this).val() == "type-3"){
// 			$("main").removeClass().width();
// 			$('main').addClass('type--3');
//     }
// });
              
            
!
999px

Console