Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
	<div class="container">
		<h1>单项目</h1>

		<p>左上角:</p>
		<div class="box box1">
			<span class="item"></span>
		</div>

		<p>顶部居中:</p>
		<div class="box box2">
			<span class="item"></span>
		</div>

		<p>垂直方向:</p>
		<div class="box box3">
			<span class="item"></span>
		</div>
		<div class="box box4">
			<span class="item"></span>
		</div>
		<div class="box box5">
			<span class="item"></span>
		</div>
		<div class="box box6">
			<span class="item"></span>
		</div>

		<h1>双项目</h1>

		<div class="box box7">
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box8">
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box9">
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box10">
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box11">
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box12">
			<span class="item"></span>
			<span class="item"></span>
		</div>

		<h1>三项目</h1>

		<div class="box box13">
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
		</div>
		
		<h1>四项目</h1>

		<div class="box box14">
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box15">
			<div class="row">
				<span class="item"></span>
				<span class="item"></span>
			</div>
			<div class="row">
				<span class="item"></span>
				<span class="item"></span>
			</div>
		</div>

		<h1>六项目</h1>

		<div class="box box16">
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box17">
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
		</div>
		<div class="box box18">
			<div class="row">
				<span class="item"></span>
				<span class="item"></span>
				<span class="item"></span>
			</div>
			<div class="row">
				<span class="item"></span>
			</div>
			<div class="row">
				<span class="item"></span>
				<span class="item"></span>
			</div>
		</div>

		<h1>九项目</h1>

		<div class="box box19">
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
			<span class="item"></span>
		</div>

		<h1>网格布局</h1>

		<p>基本网格布局</p>
		<!-- <div class="grid grid1">
			<div class="grid-cell u-1of2">1/2</div>
			<div class="grid-cell">auto</div>
			<div class="grid-cell">auto</div>
		</div>
		<div class="grid grid2">
			<div class="grid-cell">auto</div>
			<div class="grid-cell u-1of3">1/3</div>
		</div>
		<div class="grid grid3">
			<div class="grid-cell u-1of4">1/4</div>
			<div class="grid-cell">auto</div>
			<div class="grid-cell u-1of3">1/3</div>
		</div> -->
		<div class="grid grid1">
			<div class="grid-cell u-1of2">1/2</div>
			<div class="grid-cell">auto</div>
			<div class="grid-cell u-1of3">1/3</div>
			<div class="grid-cell u-1of3">1/3</div>
			<div class="grid-cell">auto</div>
			<div class="grid-cell u-1of3">1/3</div>
			<div class="grid-cell u-1of4">1/4</div>
			<div class="grid-cell u-1of3">1/3</div>
			<div class="grid-cell">auto</div>
		</div>

		<h1>圣杯布局</h1>

		<div class="grid holy-grid">
			<div class="header">header</div>
			<div class="content">
				<div class="nav">nav</div>
				<div class="main">main</div>
				<div class="ads">ads</div>
			</div>
			<div class="footer">footer</div>
		</div>
	</div>
            
          
!
            
              body {
	background-color: #232323;
}

.container {
	width: 80%;
	margin-right: auto;
	margin-left: auto;
	text-align: center;
}
h1,p {
	color: #ddd;
} 
h1 {
	padding-bottom: 10px;
	border-bottom: 1px solid #787878;
	font-weight: normal;
	font-size: 22px;
}
p {
	
}
.box {
	display: -webkit-flex;
	display: flex;
	margin: 30px auto;
	width: 120px;
	height: 120px;
	border-radius: 6px;
	background-color: #eee;
	box-shadow: 0 2px 10px 0 #111,
				inset 0 2px 0 0 #fff;
}
.box .item {
	display: inline-block;
	margin:5px;
	width: 30px;
	height:30px;
	border-radius: 30px;
	background-color:#232323;
	box-shadow:inset 5px 5px 0 0 #111;
	
}
.grid {
	display: -webkit-flex;
	display: flex;
	margin: 30px auto;
	width: 100%;
	border-radius: 6px;
	background-color: #eee;
	box-shadow: 0 2px 10px 0 #111,
				inset 0 2px 0 0 #fff;
}
.grid .grid-cell {
	margin:10px;
	height:30px;
	border-radius: 5px;
	background-color: #454545;
	line-height: 30px;
	text-align: center;
	color: #fff;
}

.box1 {
	display: flex;
}

.box2 {
	display: flex;
	justify-content: flex-end;
}

.box3 {
	display: flex;
	align-items: center;
}
.box4 {
	display: flex;
	justify-content: center;
	align-items: center;
}
.box5 {
	display: flex;
	justify-content: center;
	align-items: flex-end;
}
.box6 {
	display: flex;
	justify-content: flex-end;
	align-items: flex-end;
}

.box7 {
	display: flex;
	justify-content: space-between;
	/*justify-content: space-around;*/
}
.box8 {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}
.box9 {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	align-items: center;
}
.box10 {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	align-items: flex-end;
}

.box11 {
	display: flex;
}
.box11 .item:nth-child(2) {
	align-self: center;
}

.box12 {
	display: flex;
	justify-content: space-between;
}
.box12 .item:nth-child(2) {
	align-self: flex-end;
}

.box13 {
	display: flex;
	/*justify-content: space-between;*/
}
.box13 .item:nth-child(2) {
	align-self: center;
}
.box13 .item:nth-child(3) {
	align-self: flex-end;
}

.box14 {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-content: space-between;
}

.box15 {
	display: flex;
	flex-wrap: wrap;
	align-content: space-between;
}
.box15 .row {
	/*flex-basis: 100%;*/
	flex-grow: 1;
	display: flex;
	justify-content: space-between;
}

.box16 {
	display: flex;
	flex-wrap: wrap;
	align-content: space-between;
}

.box17 {
	display: flex;
	flex-direction: column;
	flex-wrap: wrap;
	align-content: space-between;
}

.box18 {
	display: flex;
	flex-wrap: wrap;
	/*align-content: space-between;*/
}
.box18 .row {
	display: flex;
	flex-basis: 100%;/*  这一行占据的空间是100%*/
	justify-content: space-between;
}
.box18 .row:nth-child(2) {
	justify-content: center;
}

.box19 {
	display: flex;
	flex-wrap: wrap;
}

/*.grid1 {
	display: flex;
	flex-wrap: wrap;
}
.grid1 .grid-cell {
	flex: 1;
}
.grid1 .u-1of2 {
	flex:0 0 50%;
}

.grid2 {
	display: flex;
	flex-wrap: wrap;
}
.grid2 .grid-cell {
	flex: 1;
}
.grid2 .u-1of3 {
	flex:0 0 33.333%;
}

.grid3 {
	display: flex;
	flex-wrap: wrap;
}
.grid3 .grid-cell {
	flex: 1;
}
.grid3 .u-1of3 {
	flex:0 0 33.333%;
}
.grid3 .u-1of4 {
	flex:0 0 25%;
}*/

.grid1 {
	display: flex;
	flex-wrap: wrap;
}
.grid1 .grid-cell {
	flex: 1;
}
.grid1 .u-1of2 {
	flex:0 0 50%;
}
.grid1 .u-1of3 {
	flex:0 0 33.333%;
}
.grid1 .u-1of4 {
	flex:0 0 25%;
}

.holy-grid {
	display: flex;
	flex-direction: column;
	/*flex-wrap:wrap;*/
}
.holy-grid .header,
.holy-grid .footer {
	flex:1;
	height: 40px;
	background-color: #676767;
	line-height: 40px;
	color: #fff;
}
.holy-grid .header {
	border-top-right-radius: 5px;
	border-top-left-radius: 5px;
}
.holy-grid .footer {
	border-bottom-right-radius: 5px;
	border-bottom-left-radius: 5px;
}
.holy-grid .content {
	display: flex;
	flex:1;
	min-height: 300px;
	line-height: 300px;
}
.holy-grid .nav,
.holy-grid .ads {
	flex:0 0 70px;
}
.holy-grid .main {
	flex:1;
}
.holy-grid .nav {
	order:1;
	background-color: #a1a1a1;
}
.holy-grid .ads {
	background-color: #d3d3d3;
}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console