Search code examples
cssflexboxshopifyshopify-template

Shopify 2.0 Dawn Looking to align elements on a collection page using Flex


I am trying to align items in my collection page using flex - but to no avail. I can't figure out where to put the css code. I would like the "learn more" buttons at the bottom of each product description to line up horizontally. I would also like the Descriptions, starting with "Design Edition Year" to line up horizontally as well. I did try imposing a min-height on the fragrance name - but then it is still out of alignment on mobile.

I appreciate any help.

https://test-store-colleen.myshopify.com/

password: thanksforyourhelp

Page shown below: https://test-store-colleen.myshopify.com/collections/gift-gallery

Image of collection page

A sample of some of the css that I have tried without success.

/* component-grid */
.grid {
  display: flex;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
  margin-bottom: 2rem;
  margin-left: -0.5rem;
  padding: 0;
  list-style: none;
}

@media screen and (min-width: 750px) {
  .grid {
    margin-left: -1rem;
  }
}

/* edited below to all align-items: flex-end; to align items on collection pages- Colleen */  
  
.grid__item {
  padding-left: 0.5rem;
  padding-bottom: 0.5rem;
  width: calc(25% - 0.5rem * 3 / 4);
  max-width: 50%;
  flex-grow: 1;
  flex-shrink: 0;
}

@media screen and (min-width: 750px) {
  .grid__item {
    padding-left: 1rem;
    padding-bottom: 1rem;
    width: calc(25% - 1rem * 3 / 4);
    max-width: 50%;
  }
}


Solution

  • From the looks of it you haven't actually set to flex the grid item in itself and the .learn-more-button child. This would start getting you where you want:

    ul#product-grid li.grid__item {
        display: flex;
        flex-direction: column;
    }
    
    ul#product-grid li.grid__item .learn-more-button {
        display: flex;
        flex-direction: column;
    }
    
    ul#product-grid li.grid__item .card-wrapper .card-information {
        min-height: 70px;
    }
    

    enter image description here

    Naturally, add or remove classes for specificity and media queries at will.