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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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


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.


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.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:


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.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO


                <input type="file" name="file" id="file-field" title="Загрузить фото" />
<ul id="img-list"></ul>
<div id="result"></div>
<canvas id="canvas"></canvas>


                #img-list {
  width: 50%;
  img {
    display: block;
    width: 100%;
    height: auto;
#result {
  width: 100px;
  height: 100px;
  border: 1px solid #000;


                $(document).ready(function() {
    // Консоль
    var console = $("#console");

    // Инфа о выбранных файлах
    var countInfo = $("#info-count");
    var sizeInfo = $("#info-size");

    // Стандарный input для файлов
    var fileInput = $('#file-field');
    // ul-список, содержащий миниатюрки выбранных файлов
    var imgList = $('ul#img-list');
    // Контейнер, куда можно помещать файлы методом drag and drop
    var dropBox = $('#img-container');

    // Счетчик всех выбранных файлов и их размера
    var imgCount = 0;
    var imgSize = 0;

    // Отображение выбраных файлов и создание миниатюр
    function displayFiles(files) {
        var imageType = /image.*/;
        var num = 0;
        $('#img-list li').remove();
        $.each(files, function(i, file) {
            // Отсеиваем не картинки
            if (!file.type.match(imageType)) {
                return true;
            // Создаем элемент li и помещаем в него название, миниатюру и progress bar,
            // а также создаем ему свойство file, куда помещаем объект File (при загрузке понадобится)
            var li = $('<li/>').appendTo(imgList);
            var img = $('<img/>').addClass('img-responsive').attr('id', 'img').appendTo(li);
            li.get(0).file = file;
            // Создаем объект FileReader и по завершении чтения файла, отображаем миниатюру и обновляем
            // инфу обо всех файлах
            var reader = new FileReader();
            reader.onload = (function(aImg) {
                return function(e) {
                      .one("load", draw).each(function() {
                          if(this.complete) $(this).load();
                    imgSize += file.size;

            $('.draggable:not(.nopopup)').mouseenter(function(event) {
                $('.popup').css('opacity', '1');
            }).mouseleave(function(event) {
                $('.popup').css('opacity', '0');
            $('#checkbox').change(function(event) {
                if ($(this).is(':checked')) {
                }else {
  function draw() {
     var gimg = document.getElementById('img'),
         result = document.getElementById('result'),
         canvas = document.createElement('canvas'),
         zone = canvas.getContext('2d'),
         offset = gimg.getBoundingClientRect();

    canvas.width = gimg.width;
    canvas.height = gimg.height;
    zone.drawImage(gimg, 0, 0, gimg.width, gimg.height);

    gimg.addEventListener('mousemove', function(e) {
      var data = zone.getImageData(e.clientX - (offset.left - pageXOffset), e.clientY - ( - pageYOffset), 1, 1).data,
          rgb = data[0] + ',' + data[1] + ',' + data[2]; = result.textContent = 'rgb(' + rgb  + ')'; 

    // Обработка события выбора файлов через стандартный input
    // (при вызове обработчика в свойстве files элемента input содержится объект FileList,
    //  содержащий выбранные файлы)
        change: function() {
    // Проверка поддержки File API в браузере
    if(window.FileReader == null) {
        alert('Ваш браузер не поддерживает File API!');

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