Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <h2>使用 caret-color 实现光标自定义颜色</h2>
<input class="first" type="text" value="文字蓝色,光标红色">

<div contenteditable="true">caret-color 属性不仅对于原生的输入表单控件有效,设置 contenteditable 的普通标签也适用。</div>

<h2>使用伪类 :first-line 实现光标自定义颜色, FireFox 不支持 :first-line </h2>
<input type="text" class="second" value="字体红色,光标蓝色">

<h2>综合以上两种写法解决 Safari 兼容性问题(但是没有解决IE的兼容性问题),同时解决 FireFox 不支持 :first-line 的问题 </h2>
<input type="text" class="third" value="字体红色,光标蓝色">
              
            
!

CSS

              
                h2 {
  margin: 20px;
  margin-bottom: 0px;
}
.first {
  width: 700px;
  font-size: 30px;
  margin: 20px;
  box-sizing: border-box;
  /*字体颜色    */
  color: blue;
  /*  光标颜色  */
  caret-color: red;
}

[contenteditable = "true"] {
  margin-left: 20px;
  font-size: 30px;
  color: blue;
  caret-color: yellow;
}

.second {
  width: 1000px;
  font-size: 30px;
  margin: 20px;
  box-sizing: border-box;
  color: blue;
}

.second::first-line {
  color: red;
}

.third {
  width: 1000px;
  font-size: 30px;
  margin: 20px;
  box-sizing: border-box;
  color: red;
  caret-color: blue;
}

@supports ( -webkit-mask: none ) and ( not ( caret-color: blue )) {
  .third {
    color: blue;
  }
  .third::first-line {
    color: red;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console