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

              
                -
  const icons1 = [
    {
      icon: 'fa-brands fa-wordpress',
    },
    {
      icon: 'fa-brands fa-slack',
    },
    {
      icon: 'fa-brands fa-reddit',
    },
    {
      icon: 'fa-brands fa-css3-alt',
    },
    {
      icon: 'fa-brands fa-apple',
    },
  ]
-
  const icons2 = [
    {
      icon: 'fa-brands fa-yahoo',
    },
    {
      icon: 'fa-solid fa-igloo',
    },
    {
      icon: 'fa-solid fa-blog',
    },
    {
      icon: 'fa-brands fa-brands fa-windows',
    },
    {
      icon: 'fa-brands fa-algolia',
    },
    {
      icon: 'fa-brands fa-blogger',
    },
  ]

h2.main-title Our Best Partners
.slider-container
  .slider
    .slides(data-duration='10')
      - for (var i = 0; i < 2; i++)
        .slide
          each icon, index in icons1
            i(class=`${icon.icon}`)
  .slider
    .slides.alternate(data-duration='12')
      - for (var i = 0; i < 2; i++)
        .slide
          each icon, index in icons2
            i(class=`${icon.icon}`)

              
            
!

CSS

              
                .main-title{
  position:relative;
  font-size:2.4rem;
  font-weight:200;
  padding-bottom: 2.2rem;
  margin:4rem auto 2.2rem;
  
  &::before{
    content: '';
    position: absolute;
    width: 90px;
    height:2px;
    background-color: #b2e061;
    bottom:-1px;
    left:50%;
    transform: translate3d( -50%, 0, 0 );
  }
}

.slider-container {
  overflow: hidden;
}

.slider {
  width: 100%;
  position: relative;
}

.slides {
  display: flex;
  width: 200%;
}

.slide {
  flex-basis: 50%;
  display:flex;
  align-items: center;
  
  i{
    display: block;
    flex-basis: var(--logo-width, 25%);
    font-size:clamp( 60px, 6.8vw, 120px);
    padding:clamp( 30px, 4vw, 60px ) 0;
    transition: transform .3s;
    cursor: pointer;
    
    &:hover{
      transform: scale(1.14);
    }
  }
}
              
            
!

JS

              
                window.addEventListener( 'DOMContentLoaded', ( event ) => {

  const slides = document.getElementsByClassName('slides');
  
  for ( let i = 0; i < slides.length; ++i ) {
    // 対象ラッパー要素
    const target = slides[ i ];
    // ループ1回分の時間
    const duration = parseInt( target.dataset.duration ) * 1000 || 10000;
    // スライダーの進行方向(右から左 or 左から右)
    const isAlternate = target.classList.contains( 'alternate' );
    // ロゴ数の取得
    const childNum = target.firstElementChild.children.length;
    // ロゴの幅の算出
    const logoWidth = ( (100 / childNum ) * 100 / 100 ).toFixed( 2 );
    // ロゴの幅をセット
    target.style.setProperty( '--logo-width', `${ logoWidth }%` );

    // 開始時間
    let startTime = 0;
    // 経過時間
    let elapsed = 0;
    // 進捗(0-1)
    let progress = 0;

    const loop  = ( currentTime ) => {
      if ( !startTime ) {
        startTime = currentTime;
      }
      // 現在の経過時間
      elapsed = currentTime - startTime;
      // 現在の進捗
      progress = Math.min( 1, elapsed / duration );

      // 進捗が 100%(位置が 50%)になったらリセットして再ループ
      if ( progress >= 1 ) {
        startTime = 0;
        elapsed = 0;
        progress = 0;
      }

      // スライドの位置を更新
      if ( isAlternate ) {
        // 左から右の場合
        target.style.transform = `translate3d(${ -50 + progress * 50 }%, 0, 0)`;
      } else {
        // 右から左の場合
        target.style.transform = `translate3d(-${ progress * 50 }%, 0, 0)`;
      }

      // 次のフレームをリクエストする
      window.requestAnimationFrame( loop );
    }

    // ループを開始
    window.requestAnimationFrame( loop );
  };
} );
              
            
!
999px

Console