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.


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.


                <!-- 増殖用の画像 -->
<div class="original">
  <div class="original__item">
    <img src="">
  <div class="original__item">
    <img src="">
  <div class="original__item">
    <img src="">
  <div class="original__item">
    <img src="">

<!-- 増殖する場所 -->
<div class="wrapper" id="js-wrapper">

<!-- 増殖するボタン -->
<div class="btn" id="js-btn">ボタン</div>


.original {
  display: none;

.original__item {
  // 座標を中心にしている
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -75px;
  margin-top: -75px;
  width: 150px;
  height: 150px;
  img {
    width: 100%;
    height: 100%;

.wrapper {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

.btn {
  z-index: 10;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  background: #333;
  border-radius: 100%;
  font-family: "Arial";
  color: #fff;
  text-align: center;
  line-height: 100px;
  cursor: pointer;


                // 増殖させるボタン
var $btn = document.querySelector('#js-btn');

// 増殖する場所
var $wrapper = document.querySelector('#js-wrapper');

// 増殖用の画像
var $originalItem = document.querySelectorAll('.original__item');

// 増殖アニメーション用のイージング
var easingName = [
  'Elastic.easeInOut.config(1, 0.3)',
  'ease: Circ.easeInOut'

$btn.addEventListener('click', function() {
  // ランダムで1つ、要素が選ばれて複製する
  const randNum = Math.floor(Math.random() * $originalItem.length);
  const $clone = $originalItem[ randNum ].cloneNode(true);
  // 要素を挿入する
  // 要素を拡散する
  // ---------------------------------------------------------------
  var expandAnime = {
    x: Math.floor(Math.random() * window.innerWidth - window.innerWidth / 2),
    y: Math.floor(Math.random() * window.innerHeight - window.innerHeight / 2),
    rotation: Math.floor(Math.random() * 720 - 360),
    scale: 0.2 + Math.random(),
    duration: 0.5 + Math.random() * 2.0,
    ease : easingName[Math.floor(Math.random() * easingName.length)]
  };$clone, expandAnime.duration, {
    x: expandAnime.x,
    y: expandAnime.y,
    rotation: expandAnime.rotation,
    ease: expandAnime.ease,
    scale: expandAnime.scale
  return false;