Pen Settings

HTML

CSS

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

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

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.

HTML

              
                -
      // по Маркову
      //- {name: 'Быт', percent: 25},
      //- {name: 'Лиза', percent: 25},
      //- {name: 'Налоги ', percent: 6},
      //- {name: 'Даня', percent: 25},
      //- {name: 'Ценные бумаги', percent: 10},
      //- {name: 'Работа', percent: 9},

      // в случае дефицита на быте
      //- {name: 'Быт', percent: 40},
      //- {name: 'Лиза', percent: 25},
      //- {name: 'Налоги ', percent: 6},
      //- {name: 'Даня', percent: 24},
      //- {name: 'Работа', percent: 5},
      
      // Распределении студии v2
      //- {name: 'Быт', percent: 25},
      //- {name: 'Лиза', percent: 19},
      //- {name: 'Даня', percent: 19},
      //- {name: 'Фриланс', percent: 12},
      //- {name: 'Отпуск/Отдых', percent: 7},
      //- {name: 'Налоги', percent: 6},
      //- {name: 'Прибыль', percent: 12},
      
      
      // Распределении студии v1
      //- {name: 'Быт', percent: 16.7},
      //- {name: 'Лиза', percent: 12},
      //- {name: 'Даня', percent: 12},
      //- {name: 'Амортизация/Софт', percent: 1.9},
      //- {name: 'Офис', percent: 1.4},
      //- {name: 'Обучение', percent: 2},
      //- {name: 'Маркетинг', percent: 10},
      //- {name: 'Отпуск', percent: 10},
      //- {name: 'Налоги', percent: 6},
      //- {name: 'Прибыль', percent: 24},
      //- {name: 'НЗ', percent:4},
      
      // до Маркова
      //- {name: 'Быт', percent: 38},
      //- {name: 'Лиза', percent: 12},
      //- {name: 'Налоги ', percent: 6},
      //- {name: 'Даня', percent: 9},
      //- {name: 'Инвестиции', percent: 8},
      //- {name: 'Работа', percent: 12},
      //- {name: 'Дом', percent: 5},
      //- {name: 'Отдых', percent: 5},
      //- {name: 'Улучшайзер', percent: 5},
      
      // Распределении студии (markov 2021)



   //- var percents = [
   //-    {name: 'Налоги', percent: 6},
   //-    {name: 'Развитие', percent: 15},
   //-    {name: 'В семью', percent: 79},    
   //- ];
   //- var percents2 = [
   //-    {name: 'Быт', percent: 47},
   //-    {name: 'Лиза', percent: 15},
   //-    {name: 'Даня', percent: 15},
   //-    {name: 'Утряска', percent: 6},
   //-    {name: 'На покупки', percent: 10},
   //-    {name: 'Отпуск', percent: 7}
   //- ]
   
   //- var percents = [
   //-    {name: 'Налоги', percent: 6},
   //-    {name: 'Развитие', percent: 15},
   //-    {name: 'В семью', percent: 79},    
   //- ];
   //- var percents2 = [
   //-    {name: 'Быт', percent: 50},
   //-    {name: 'Даня', percent: 15},
   //-    {name: 'Утряска', percent: 13},
   //-    {name: 'На покупки', percent: 10},
   //-    {name: 'Отпуск', percent: 12}
   //- ]   
   
   //- var percents = [
   //-    {name: 'Налоги', percent: 6},
   //-    {name: 'Развитие', percent: 10},    
   //-    {name: 'В семью', percent: 84},    
   //- ];
   //- var percents2 = [
   //-    {name: 'Быт', percent: 50},
   //-    {name: 'Даня', percent: 15},
   //-    {name: 'Утрсяка, отпуск, покупки', percent: 35},
   //- ]    
   
   //- var percents = [
   //-    {name: 'Налоги', percent: 6},
   //-    {name: 'Развитие', percent: 10},    
   //-    {name: 'В семью', percent: 84},    
   //- ];
   //- var percents2 = [
   //-    {name: 'Быт', percent: 50},
   //-    {name: 'Даня', percent: 15},
   //-    {name: 'Лиза', percent: 15},
   //-    {name: 'Утрсяка, отпуск, покупки', percent: 20},
   //- ]   

   var percents = [
      {name: 'Налоги', percent: 6},
      {name: 'Развитие', percent: 10},    
      {name: 'На распределение', percent: 84}
   ];





//- h1 Порог до приоритетов 200 000

.common-block.js-personal
  //- h2.common-block-title Первое распределение
  label
     span Общая сумма  
     input.field.js-sum(type='' placeholder="0.00" data-target="")
     span.sum-percent.js-sum-percent Сумма процентов #[span 100]%
    
     span Сумма расходов для вычета
     input.field.js-consumption(type='' placeholder="0.00" data-target="")
  
  .result.js-result
    each item in percents
      label.result-item(data-percent=item.percent)
         span.result-label=item.name
         span.result-value 0
         input(type="checkbox")
         
//- .common-block.js-personal
//-   h2.common-block-title Второе распределение
//-   label.common-block-flex-row 
//-      input.field.js-sum-2(type='' placeholder="0.00" data-target="")
//-      span.sum-percent.js-sum-percent Сумма процентов #[span 100]%
  
//-   .result.js-result.js-result-family
//-     each item in percents2
//-       label.result-item.result-item-2(data-percent=item.percent)
//-          span.result-label=item.name
//-          span.result-value 0
//-          input(type="checkbox")         

              
            
!

CSS

              
                :root {
   --bg-main: #131419;
   --bg-second: #1A1C22;
   --green: #4EBE96;
   --orange: #f09867;
   --purple: #6166DC;
}

body {
   padding: 40px;
   font-family: 'Jost';
   background-color: var(--bg-main);
   color: #fff;
}

label {
   & > span {
      display: block;
      margin-bottom: 5px;
   }
}

.js-personal .result {
   margin-top: 40px;
}

.js-invest .field {
   margin-bottom: 40px;
}

label {
   display: block;
   width: 100%;
}

.field {
   background-color: #F8F8F8;
   font-size: 30px;
   padding: 15px 15px;
   max-width: 215px;
   width: 100%;
   border: none;
   outline: none;
   font-weight: bold;
   border-radius: 6px;
   @media (max-width: 650px) {
      width: 100%;
      max-width: 90%;
   }     
}

.common-block {
   margin-bottom: 100px;
   &-title {
      font-size: 36px;
   }
   &-subtitle {
      font-size: 28px;
      span {
         opacity: 0.2;
      }
   }   
   &-flex-row {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
   }
   .sum-percent {
      font-weight: bold;
      opacity: 0.2;
      font-size: 20px;
      margin-bottom: 30px;
      @media (max-width: 650px) {
         width: 100%;
      }       
   }
}

.result {
   display: flex;
   align-items: flex-start;
   width: 100%;
   flex-wrap: wrap;
   gap: 10px;
   
   &-item {
      border-radius: 6px;
      background-color: var(--green);
      padding: 10px 15px;
      cursor: pointer;
      margin: 1px;
      width: 28%;
      padding-right: 10px;
      transition: .3s all;
      @media (max-width: 650px) {
         width: 100%;
      }
   }
   &-label {
      font-weight: 500;
      font-size: 16px;   
   }
   &-value {
      font-size: 40px;
      font-weight: bold;
      width: 100%;
      display: block;
      @media (max-width: 650px) {
         font-size: 35px;
      } 
   }
}

.js-project-input-result {
   font-size: 40px;
   font-weight: bold;
   width: 100%;
   display: block;
   @media (max-width: 650px) {
      font-size: 35px;
   } 
}
              
            
!

JS

              
                

/* ============================================================================




РАБОТАЕТ НА СОПЛЯХ 
НЕ ТРОГАЙТЕ К ЧЕРТЯМ!





============================================================================ */










$('.js-sum, .js-consumption').on('input', function() {
   var sum = $('.js-sum').val(),
       sumForTax = sum;
       consumption = $('.js-consumption').val(),
       sumWithConsumption = sum - consumption;

   $(this).closest('.common-block').find('.result-item').each(function(i, item) {
      var percentItem = $(item).attr('data-percent'),
          title = $(item).find('.result-label').text(),
          sum = sum;
      
      if(title == 'Развитие' || title == 'В семью' || title == 'На распределение') {
         sumForItem = (sumWithConsumption / 100 * +percentItem).toFixed(2);
      } else {
         sumForItem = (sumForTax / 100 * +percentItem).toFixed(2);
      }

      
      if (title == 'В семью' || title == 'На распределение') {
         sumForItem = Number(sumForItem); 
         
         $('.js-sum-2').val(sumForItem);
         var sum = sumForItem;
        
         $('.js-result-family').find('.result-item').each(function(i, item) {
            var percentItem = $(item).attr('data-percent'),
                sumForItem = (Number(sum) / 100 * +percentItem).toFixed(2);

            sumForItem = Number(sumForItem);
            $(item).find('.result-value').text(Number(sumForItem).toFixed());
         })         
         
      }
          
      sumForItem = Number(sumForItem).toLocaleString('ru'); 
      $(item).find('.result-value').text(sumForItem);
      
      
  })
   
});



$('.js-sum-2').on('input', function() {
   var sum = $(this).val();

   $(this).closest('.common-block').find('.result-item').each(function(i, item) {
      var percentItem = $(item).attr('data-percent'),
          sumForItem = (sum / 100 * +percentItem).toFixed(2);
      
      sumForItem = Number(sumForItem).toLocaleString('ru'); 
      $(item).find('.result-value').text(sumForItem);
  })
   
});


$('.js-personal').each(function(i, item) {
   var percent = 0;
   
   $(item).find('.result-item').each(function(i, item) {
      var parent = $(this).closest('.js-personal'),
          percentItem = $(item).attr('data-percent');

      percent += Number(percentItem);
      parent.find('.js-sum-percent span').text(percent);
   });   
   
})




              
            
!
999px

Console