<main>
  <h2>Container max-width: 700px</h2>
  <p>Looks good on both small and large resolutions</p>
  <section class="container-wide">
    <article class="card">
      <div class="card__wrapper">
        <figure>
          <img class="card__image" src="https://picsum.photos/id/2/500/500" />
        </figure>
        <div>
          <h3 class="card__title">This is an item title</h3>
          <div>
            <p>
              <small class="card__description">
                This is an item description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque convallis ultrices nisl eget dapibus. Aliquam auctor mi sed porttitor lacinia. In condimentum tempus aliquam.</small>
            </p>
          </div>
          <div class="card__actions">
            <strong class="card__price">$2,000</strong>
            <button class="card__button">Add to cart</button>
          </div>
        </div>
      </div>
    </article>
  </section>

  <h2>Container max-width: 380px</h2>
  <p>Looks good only on small resolutions. On large resolution layout is broken.</p>
  <section class="container-narrow">
    <article class="card">
      <div class="card__wrapper">
        <figure>
          <img class="card__image" src="https://picsum.photos/id/2/500/500" />
        </figure>
        <div>
          <h3 class="card__title">This is an item title</h3>
          <div>
            <p>
              <small class="card__description">
                This is an item description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque convallis ultrices nisl eget dapibus. Aliquam auctor mi sed porttitor lacinia. In condimentum tempus aliquam.</small>
            </p>
          </div>
          <div class="card__actions">
            <strong class="card__price">$2,000</strong>
            <button class="card__button">Add to cart</button>
          </div>
        </div>
      </div>
    </article>
  </section>

  <h2>Expected result on narrow containers</h2>
  <p>Ideally, we would like to use a small resolution layout for narrow containers</p>
  <section class="container-narrow">
    <article class="card--narrow">
      <figure>
        <img class="card__image" src="https://picsum.photos/id/2/500/500" />
      </figure>
      <div>
        <h3 class="card__title">This is an item title</h3>
        <div>
          <p>
            <small class="card__description">
              This is an item description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque convallis ultrices nisl eget dapibus. Aliquam auctor mi sed porttitor lacinia. In condimentum tempus aliquam.</small>
          </p>
        </div>
        <div class="card__actions">
          <strong class="card__price">$2,000</strong>
          <button class="card__button">Add to cart</button>
        </div>
      </div>
    </article>
  </section>
</main>
body {
  margin: 0 auto;
  line-height: 1.4;
  font-size: 18px;
  padding: 0 1em;
}

h2 {
  margin: 1em 0 0.5em;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

figure {
  margin: 0;
}

.card__title {
  margin: 0 0 1em;
}

.card__wrapper {
  display: grid;
  grid-gap: 1.5em;
  grid-template-rows: auto auto;
  background: #e7e7e7;
  padding: 1em;
  border-radius: 0.5em;
  margin-bottom: 1em;
}

.card--narrow {
  display: grid;
  grid-gap: 1.5em;
  grid-template-rows: auto auto;
  background: #e7e7e7;
  padding: 1em;
  border-radius: 0.5em;
  margin-bottom: 1em;
}

.card__image {
  object-fit: cover;
  object-position: center;
  width: 100%;
  height: 150px;
  border-radius: 0.5em;
  overflow: hidden;
}

.card__actions {
  display: grid;
  grid-gap: 1em;
  grid-template-columns: auto auto;
  align-items: center;
}

.card__price {
  font-size: 1.25em;
  display: inline-block;
  background-color: rgba(0, 0, 0, 0.15);
  text-align: center;
  padding: 0.15em;
}

.card__description {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card__button {
  border-radius: 0;
  border: 0;
  background-color: darkred;
  color: #fff;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.5em;
}

.container-wide {
  max-width: 700px;
}

.container-narrow {
  max-width: 380px;
}

@media screen and (min-width: 568px) {
  .card__wrapper {
    align-items: center;
    grid-gap: 1.5em;
    grid-template-rows: auto;
    grid-template-columns: 150px auto;
  }

  .card__image {
    min-width: auto;
    height: auto;
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.