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. 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

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

              
                <p>这虽是简单的一段文字,却有大量的 CSS3 属性运用</p>

<div class="container">
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"><span></span></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem" data-foo="bar1"></div>
	<div class="elem" data-foo="bar2"></div>
	<div class="elem"></div>
	<div class="elem"></div>
	<div class="elem"></div>
</div>
              
            
!

CSS

              
                p{
	font-size: 16px;
	width: 420px;
	margin: 20px auto 0;
	text-align:center;
}

.container{
	width: 420px;
	margin:50px auto 0;
	overflow: hidden;
	padding:5px;
}

.elem{
	width:30px;
	height:30px;
	margin:4px;
	background-color:#A0DFAC;
	float:left;
}

.elem span{
	position:absolute;
	top:5px;
	left:5px;
	right:5px;
	bottom:5px;
	border:2px solid #fff;
}

/*定义首个文字属性*/
p::first-letter{
	background-color: #666;
	color: #FFF;
	font-size: 24px;
	font-style:normal;
	display: inline-block;
	padding: 0 5px;
	border-radius: 3px;
	margin-right: 2px;
	font-family: serif;
}

p::first-line{
	font-size: 18px;
	text-transform: smallcaps;
	font-style: italic;
	text-decoration: underline;
}

/* 第一个元素和最后一个元素为紫色 */

.elem:first-child,
.elem:last-child{
	background-color:#948bd8;
}

/* 对为元素序号为奇数的运用 border-radius*/

.elem:nth-child(odd){
	border-radius:50%;
}

/* 使第六个元素变为红色 */

.elem:nth-child(6){
	background-color:#cb6364;
}

/* 对 span 行内元素运用样式 */

.elem:not(:empty){
	background-color:#444;
	position:relative;
	-webkit-transform:rotate(25deg);
	transform:rotate(25deg);

}

/* 通过属性定位元素并运用样式 */

.elem[data-foo=bar1]{
	background-color:#aaa;
}

.elem[data-foo=bar2]{
	background-color:#d7cb89;
}

/* 模糊匹配,对含有data-foo=bar 的元素运用样式 */

.elem[data-foo^=bar]{
	width: 16px;
	height: 16px;
	margin: 11px;
}

/* 对 data-foo=bar2 后面的元素运用属性*/

.elem[data-foo=bar2] + .elem{
	background-color:#666;
}
              
            
!

JS

              
                
              
            
!
999px

Console