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

              
                <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css">

<div role="form" class="wpcf7" lang="ja" dir="ltr">
  <form action="" method="post" class="wpcf7-form" enctype="multipart/form-data" novalidate="novalidate">
    <div class="img_form">
      <a class="del"></a>
      <label class="up_link">
        画像を選択
        <span class="wpcf7-form-control-wrap sample">
          <input type="file" name="sample" size="40" class="wpcf7-form-control wpcf7-file" accept=".jpg,.jpeg,.png,.gif" aria-invalid="false">
        </span>
      </label>
    </div>
  </form>
</div>
              
            
!

CSS

              
                label.up_link {
  display: block;
  cursor: pointer;
  background: #333;
  color: #fff;
  font-size: 2em;
  line-height: 5;
  text-align: center;
}
.up_link::before{
  font-weight: 900;
  font-family: "Font Awesome 5 Free";
  content: "\f030";
  margin-right: .3em;
}
label.up_link + img{
  width: 100%;
}
label.up_link input{
  display: none;
}
.img_form {
  position: relative;
  width: 300px;
  margin: 0 auto;
}
a.del{
  text-decoration: none;
}
a.del::after{
  position: absolute;
  top: 5px;
  right: 5px;
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  content: "\f057";
  font-size: 2.0em;
  color: #000;
}
a.del::before{
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 1.8em;
  height: 1.8em;
  background: #fff;
  border-radius: 50%;
}
              
            
!

JS

              
                jQuery(function () {

    // 添付画像の表示する
    jQuery('form').on('change', 'input[type="file"]', function (e) {
        var file = e.target.files[0];
        var reader = new FileReader();
        var img_form = jQuery(e.target).closest('.img_form');
        var label = img_form.find('.up_link');
        var del = img_form.find('.del');
        var pic = img_form.find('.up_file');
        pic = jQuery('<img src="" alt="" class="up_file">');
        label.after(pic);

        reader.onload = function (e) {
            pic.attr('src', e.target.result);
            pic.css('display', 'block');
            label.css('display', 'none');
            del.css('display', 'block');
        };
        reader.readAsDataURL(file);
    });

    // 写真削除
    jQuery(document).on('click', '.del', function (e) {
        var wpcf7 = jQuery(e.target).closest('.wpcf7');
        var img_form = jQuery(e.target).closest('.img_form');
            img_form.find('.up_file').remove();
            img_form.find('.up_link').css('display', 'block');
            img_form.find('input').val('');
            img_form.find('.del').css('display', 'none');
            img_form.replaceWith(img_form.clone(true));
    });
    jQuery('.up_file').css('display', 'none');
    jQuery('.del').css('display', 'none');
});
              
            
!
999px

Console