Pen Settings



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


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


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.



Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO


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.


Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.


Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

PRO members can see and edit the Pen thumbnail here after the Pen has been saved.


                <script type="text/template" id="template">
  <view id="container">
    <text id="testText" class="redText" value="{{= it.title }}"></text>

<script id="style">
window.styleValue = {
  container: {
    width: 800,
    height: 400,
    backgroundColor: '#f3f3f3',
    justifyContent: 'center',
    alignItems: 'center',
  testText: {
    color: '#ffffff',
    width: '100%',
    height: '100%',
    lineHeight: 400,
    fontSize: 80,
    textAlign: 'center',
  // 文字的最终颜色为#ff0000
  redText: {
    color: '#ff0000',

<canvas id="canvas">




                import Layout from "";
import * as dot from "";

 * 只需要在Web端调试场景下引用
 * 引入minigame-canvas-engine-devtools之后,layoutDevtools会自动挂载到windows
import LayoutDevTools from "";

const template = document.getElementById('template').innerHTML;
const style = eval(document.getElementById("style").innerHTML);

const it = {
  title: 'hello canvas'

// 将XML模板编译成XML字符串
let tempFn = dot.template(template);
let resultText = tempFn(it);

let canvas = document.getElementById('canvas');
let context = canvas.getContext('2d');

Layout.init(resultText, style);

const container = Layout.getElementsById('container')[0];

// 设置canvas的尺寸和样式的container比例一致 = / 2 + 'px'; = / 2 + 'px';
canvas.width =;
canvas.height =;



Why did the programmer quit her job? She didn't get arrays.