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

              
                <div id="calculator">
<div class="element" data-element="file_upload01"><label>file_upload01</label><input id="fileinput" class="calc-prop" data-identifier="file_upload01" type="file" name="properties[file_upload01]"><p id="fileName01">選択されていません</p></div>
<div class="element" data-element="file_upload02"><label>file_upload02</label><input id="fileinput" class="calc-prop" data-identifier="file_upload02" type="file" name="properties[file_upload02]"><p id="fileName02">選択されていません</p></div>
</div>
              
            
!

CSS

              
                #calculator .element {
    padding: 3px 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}
.element[data-element="file_upload01"]>label:before, .element[data-element="file_upload02"]>label:before {
    content: '';
    background: url(https://cdn.shopify.com/s/files/1/0544/8158/4301/files/download-icon.png?v=1661250299&b=allow_avif);
    width: 16px;
    height: 16px;
    display: inline-block;
    top: 3px;
    position: relative;
    margin-right: 5px;
}
#calculator .element[data-element="file_upload01"] label, #calculator .element[data-element="file_upload02"] label {
    display: block !important;
    font-size: 0 !important;
    z-index: 1;
    pointer-events: none;
}
.element[data-element="file_upload01"]>label, .element[data-element="file_upload02"]>label {
    display: none;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    color: #50AEBA !important;
    border: 2px solid #50aeba;
    border-radius: 20px;
}
.element[data-element="file_upload01"]>label:after, .element[data-element="file_upload02"]>label:after {
    content: 'ファイルを選択';
    font-size: 13px;
    font-weight: bold;
}
#calculator .element[data-element="file_upload01"] label, #calculator .element[data-element="file_upload02"] label{
    width: 80%;
}
.element[data-element="file_upload01"]>label,
.element[data-element="file_upload02"]>label{
    background: #fff;
    padding: 5px 0;
}
.element[data-element="file_upload01"]>label:after,
.element[data-element="file_upload02"]>label:after {
    content: 'ファイルを選択';
    font-size: 13px;
    font-weight: bold;
}
#fileName01,#fileName02 {
    width: 100%;
    text-align: center;
}
.element[data-element="file_upload01"],
.element[data-element="file_upload02"]{
    flex-flow: column;
    margin-bottom: 0 !important;
    padding-top: 10px !important;
}
textarea.calc-prop[name="properties[サイズ内訳]"] {
    min-height: 140px;
}
.element strong {
    font-weight: bold;
}
.element[data-element="file_format"] {
    margin: 10px 20px;
}
.element[data-element="file_upload01"],
.element[data-element="file_upload02"] {
    position: relative;
}

.element[data-element="file_format"] {
    border: 1px solid #ADADAD;
    padding: 0 20px 20px !important;
    margin: 20px;
    width: calc(100% - 40px) !important;
}
.element[data-element="file_format"] label,
.element[data-element="attention_file_upload"] label {
    width: 100% !important;
}
input#fileinput.calc-prop[name="properties[file_upload01]"], input#fileinput.calc-prop[name="properties[file_upload02]"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    left: 0;
    letter-spacing: 22px;
}
#calculator .element[data-element="file_upload01"] label.progress-bar, #calculator .element[data-element="file_upload02"] label.progress-bar {
    position: relative;
    overflow: hidden;
}
#calculator .element[data-element="file_upload01"] label.progress-bar:after, #calculator .element[data-element="file_upload02"] label.progress-bar:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    background: #52aeb9;
    width: 100%;
    height: 100%;
    z-index: 0;
    animation-name: test_box_slide;
    animation-duration:5s;
    animation-fill-mode: forwards;
    transform: translateX(-100%);
}
@keyframes test_box_slide {
  0% {
    transform: translate(-100%,0)
  }
  100% {
    transform: translate(0,0)
  }
}
#calculator .element[data-element="file_upload01"] label.upload-complete, #calculator .element[data-element="file_upload02"] label.upload-complete {
    background: #52aeb9;
}
.element[data-element="file_upload01"]>label.upload-complete:after, .element[data-element="file_upload02"]>label.upload-complete:after {
    content: 'アップロード準備完了';
    color: #fff;
}
@media screen and (max-width: 1024px){
    .element[data-element="file_format"] {
        margin: 20px;
        width: calc(100% - 40px) !important;
    }
    #calculator .element[data-element="file_upload01"] label,
    #calculator .element[data-element="file_upload02"] label {
        width: 100% !important;
        margin: 5px 0 !important;
    }
}
              
            
!

JS

              
                $(function() {
  $('#calculator .element input[type=number]').change( function() {
    if($('#calculator .element input[type=number]').val() == 0 ) {
      $('.section-product-detail__btn-cart').addClass('active');
    } else {
      $('.section-product-detail__btn-cart').removeClass('active');
    }
  });
});

function bytesToSize(bytes) {
   var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
   if (bytes == 0) return '0 Byte';
   var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
   return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};

    $('input[data-identifier="file_upload01"]').change(function() {
      var file01 = $('#fileinput[data-identifier="file_upload01"]')[0].files[0];
      
      //upload file over 10MB(10240byte) alert
      if(file01.size>10240000){
        window.alert('ファイルが10MBを超えています');
        $(this).val('');
        return;
      }
      //upload file over 10MB(10240byte) alert
      
      $('#calculator .element[data-element="file_upload01"] label').removeClass('upload-complete');
      $('#fileName01').html(file01.name + ' (' + bytesToSize(file01.size) + ')');
      $('#calculator .element[data-element="file_upload01"] label').addClass('progress-bar');
      setTimeout(function(){
        $('#calculator .element[data-element="file_upload01"] label').removeClass('progress-bar');
        $('#calculator .element[data-element="file_upload01"] label').addClass('upload-complete');
      }, 5000); //5 second
    });

    $('input[data-identifier="file_upload02"]').change(function() {
      var file02 = $('#fileinput[data-identifier="file_upload02"]')[0].files[0];
      
      //upload file over 10MB(10240byte) alert
      if(file02.size>10240000){
        window.alert('ファイルが10MBを超えています');
        $(this).val('');
        return;
      }
      //upload file over 10MB(10240byte) alert
      
      $('#calculator .element[data-element="file_upload02"] label').removeClass('upload-complete');
      $('#fileName02').html(file02.name + ' (' + bytesToSize(file02.size) + ')');
      $('#calculator .element[data-element="file_upload02"] label').addClass('progress-bar');
      setTimeout(function(){
        $('#calculator .element[data-element="file_upload02"] label').removeClass('progress-bar');
        $('#calculator .element[data-element="file_upload02"] label').addClass('upload-complete');
      }, 5000); //5 second
    });
              
            
!
999px

Console