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 data = [
       {
        src: 'https://images.unsplash.com/photo-1608667508764-33cf0726b13a',
        title: 'Jhang Air Max sneakers',
        desc: 'In this product card, the link goes on top of all the content except the button. It overlaps even this text. But if the text and other elements are assigned position: relative, then such elements will be on the top of the link.',
        in_stock: 'In stock',
        price: '6452',
        price_old: '8054',
        btn_text: 'Add to your cart',
      },
      {
        src: 'https://images.unsplash.com/photo-1608666634759-4376010f863d',
        title: 'Кроссовки Shang Air Max',
        desc: 'В этой карточке товара ссылка идет поверх всего контента, кроме кнопки. Она перекрывает даже этот текст. Но если тексту и другим элементам присвоить position: relative, то такие элементы будут поверх ссылки.',
        in_stock: 'В наличии',
        price: '6452',
        price_old: '8054',
        btn_text: 'Добавить в корзину',
      },
      {
        src: 'https://images.unsplash.com/photo-1608667508764-33cf0726b13a',
        title: 'Valenki from Matveyevna',
        desc: 'Matveyevna makes felt boots very well and even supplies them to 112 countries in South Africa.',
        in_stock: 'In stock',
        price: '11680',
        price_old: '15068',
        btn_text: 'Добавить в корзину',
      },
             {
        src: 'https://images.unsplash.com/photo-1608667508764-33cf0726b13a',
        title: 'Jhang Air Max sneakers',
        desc: 'In this product card, the link goes on top of all the content except the button. It overlaps even this text. But if the text and other elements are assigned position: relative, then such elements will be on the top of the link.',
        in_stock: 'In stock',
        price: '6452',
        price_old: '8054',
        btn_text: 'Add to your cart',
      },
      {
        src: 'https://images.unsplash.com/photo-1608666634759-4376010f863d',
        title: 'Кроссовки Shang Air Max',
        desc: 'В этой карточке товара ссылка идет поверх всего контента, кроме кнопки. Она перекрывает даже этот текст. Но если тексту и другим элементам присвоить position: relative, то такие элементы будут поверх ссылки.',
        in_stock: 'В наличии',
        price: '6452',
        price_old: '8054',
        btn_text: 'Добавить в корзину',
      },
      {
        src: 'https://images.unsplash.com/photo-1608667508764-33cf0726b13a',
        title: 'Valenki from Matveyevna',
        desc: 'Matveyevna makes felt boots very well and even supplies them to 112 countries in South Africa.',
        in_stock: 'In stock',
        price: '11680',
        price_old: '15068',
        btn_text: 'Добавить в корзину',
      },
             {
        src: 'https://images.unsplash.com/photo-1608667508764-33cf0726b13a',
        title: 'Jhang Air Max sneakers',
        desc: 'In this product card, the link goes on top of all the content except the button. It overlaps even this text. But if the text and other elements are assigned position: relative, then such elements will be on the top of the link.',
        in_stock: 'In stock',
        price: '6452',
        price_old: '8054',
        btn_text: 'Add to your cart',
      },
      {
        src: 'https://images.unsplash.com/photo-1608666634759-4376010f863d',
        title: 'Кроссовки Shang Air Max',
        desc: 'В этой карточке товара ссылка идет поверх всего контента, кроме кнопки. Она перекрывает даже этот текст. Но если тексту и другим элементам присвоить position: relative, то такие элементы будут поверх ссылки.',
        in_stock: 'В наличии',
        price: '6452',
        price_old: '8054',
        btn_text: 'Добавить в корзину',
      },
      {
        src: 'https://images.unsplash.com/photo-1608667508764-33cf0726b13a',
        title: 'Valenki from Matveyevna',
        desc: 'Matveyevna makes felt boots very well and even supplies them to 112 countries in South Africa.',
        in_stock: 'In stock',
        price: '11680',
        price_old: '15068',
        btn_text: 'Добавить в корзину',
      },
    ];

   //- parameters for unsplash images
   const parameters = 'crop=edges&cs=tinysrgb&fit=crop&fm=jpg&w=600&h=450&q=80';

each entry in data
   .product-card
      a.product-card__image(href="https://aharito.ru", target="_blank")
         img(src=entry.src + '?' + parameters, alt="Product List Card UI")
      .product-card__body
         a.product-card__title(href="https://aharito.ru")= entry.title
         .product-card__desc= entry.desc
         .product-card__stock= entry.in_stock
         .product-card__price.price
            span.price__current= entry.price + 'р'
            span.price__old= entry.price_old + 'р'
         .product-card__labels
            span.label.label_hit Хит
            span.label.label_sale Скидка -25%
      .product-card__btn
         button.btn.btn_product(type="button")= entry.btn_text

              
            
!

CSS

              
                *,
*:before,
*:after {
   box-sizing: border-box;
}

body {
   display: grid;
   grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
   grid-auto-rows: auto;
   gap: 30px;
   padding: 30px;
}

.product-card {
   font-family: Montserrat;
}

.product-card {
   $this: &;
   overflow: hidden;
   display: flex;
   flex-direction: column;
   // Псевдо-рамка
   box-shadow: 0 0 0 1px rgba($color: #d2d2d2, $alpha: 0.5);
   border-radius: 12px;
   &,
   & *::before,
   & *:not(.btn) {
      transition: all 0.2s ease-in-out;
   }
   a {
      text-decoration: none;
   }
   &:hover {
      box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.1);
   }
   &:active,
   &:focus {
      box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.3);
   }
   // .product-card__image
   &__image {
      position: relative;
      display: flex;
      &::before {
         content: "";
         display: block;
         position: absolute;
         top: 0;
         left: 0;
         right: 0;
         bottom: 0;
         background: linear-gradient(
            0deg,
            rgba(104, 187, 121, 0.24) 0px,
            rgba(104, 187, 121, 0) 24px
         );
         opacity: 0;
         #{$this}:hover & {
            opacity: 1;
         }
      }
      img {
         max-width: 100%;
      }
   }

   // .product-card__body
   &__body {
      position: relative;
      display: flex;
      flex-direction: column;
      padding: 32px 25px 0 25px;
      flex-grow: 1;
   }

   // .product-card__title
   &__title {
      margin-bottom: 11px;
      color: var(--01, #161616);
      font-size: 16px;
      font-weight: 600;
      line-height: 125%;
      &:hover,
      #{$this}:hover & {
         color: #68bb79;
      }
      &:active,
      #{$this}:active & {
         color: #29803b;
      }
      &:focus,
      #{$this}:focus & {
         color: #29803b;
      }
      &::after {
         content: "";
         display: block;
         position: absolute;
         top: 0;
         left: 0;
         right: 0;
         bottom: 0;
      }
   }

   // .product-card__desc
   &__desc {
      --lines-count: 5;
      /* position: relative; */
      margin-bottom: 11px;
      color: #6d6d6d;
      font-size: 12px;
      font-weight: 400;
      line-height: 120%;
      display: -webkit-box;
      -webkit-line-clamp: var(--lines-count);
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
      height: calc(12px * 1.2 * var(--lines-count));
   }

   // .product-card__stock
   &__stock {
      display: flex;
      align-items: center;
      color: var(--02, #68bb79);
      font-size: 14px;
      font-weight: 500;
      line-height: 125%;
      margin-top: auto;
      margin-bottom: 10px;

      &::before {
         content: "";
         flex: 0 0 6px;
         height: 6px;
         width: 6px;
         border-radius: 50%;
         background: var(--02, #68bb79);
         margin-right: 8px;
      }
   }

   // .product-card__price
   &__price {
      margin-bottom: 12px;
   }

   // .product-card__labels
   &__labels {
      position: absolute;
      top: 0;
      transform: translate(0, -10px);
      left: 0;
      width: 100%;
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      padding: 0 25px;

      .label {
         display: flex;
         justify-content: center;
         align-items: center;
         color: var(--03, #fff);
         font-size: 14px;
         font-weight: 500;
         line-height: 1;
         border-radius: 10px;
         padding: 0 12px;
         height: 2em;

         &_hit {
            background: var(--02, #68bb79);
            text-transform: uppercase;
         }

         &_sale {
            background: #e86b6b;
         }
      }
   }

   // .product-card__price
   .price {
      display: flex;
      align-items: flex-end;

      &__current {
         color: var(--01, #161616);
         font-size: 18px;
         font-weight: 700;
         line-height: 125%;
      }

      &__old {
         margin-left: 7px;
         color: var(--05, #b7b7b7);
         font-size: 14px;
         font-weight: 500;
         line-height: 125%;
         text-decoration-line: line-through;
      }
   }

   // .product-card__btn
   &__btn {
      text-align: center;
      margin-bottom: 25px;

      & > .btn_product {
         position: relative;
         #{$this}:hover & {
            --btn-start-color: #68bb79;
            --btn-start-border: 1px solid #68bb79;
         }
      }
   }
}

.btn {
   position: relative;
   display: inline-flex;
   justify-content: center;
   align-items: center;
   box-shadow: none;
   border: none;
   outline: none;
   cursor: pointer;
   text-transform: none;
   text-shadow: none;
   text-decoration: none;
   white-space: nowrap;
   user-select: none;
   color: var(--btn-start-color);
   background: var(--btn-start-background);
   border: var(--btn-start-border);
   padding: var(--btn-start-padding);
   height: var(--btn-height);
   border-radius: 9999px;
   font-family: Montserrat;
   font-weight: 500;
   font-size: 14px;
   line-height: 18px;
   transition-property: color, background-color, border-color, opacity,
      box-shadow;
   transition-duration: var(--duration-normal);
   transition-timing-function: ease-in-out;
   &:focus {
      outline: none;
   }
   &:hover {
      color: var(--btn-hover-color);
      border: var(--btn-hover-border);
      padding: var(--btn-hover-padding);
      background: var(--btn-hover-background);
   }
   &:active,
   &:focus {
      color: var(--btn-focus-color);
      border: var(--btn-focus-border);
      padding: var(--btn-focus-padding);
      background: var(--btn-focus-background);
   }
}

.btn_product {
   --btn-start-color: #b7b7b7;
   --btn-hover-color: #ffffff;
   --btn-focus-color: #ffffff;
   --btn-start-background: transparent;
   --btn-hover-background: linear-gradient(135deg, #29803b 0%, #68bb79 100%);
   --btn-focus-background: #29803b;
   --btn-start-border: 1px solid #b7b7b7;
   --btn-hover-border: 0;
   --btn-focus-border: 0;
   --btn-start-padding: 0 24px;
   --btn-hover-padding: 0 25px;
   --btn-focus-padding: 0 25px;
   height: 48px;
}

              
            
!

JS

              
                
              
            
!
999px

Console