Search Results Out of Line On Some Pages

PastorClez
New Member
4 0 0

When I search something, (in this case "TOMY") I have a issue where for this search for example on page 4 & 5 the search results are out of line

Here's a link to my website (on page 3 of "TOMY") https://kaikkistore.com/search?page=4&q=tomy&type=product

The code for my search results are here:

{% paginate search.results by 12 %}
<div class="page-width">
  {% if search.performed == false %}
    <div class="text-center">
      <h1 class="h2">{{ 'general.search.title' | t }}</h1>
  {% else %}
    <div class="section-header text-center">
      <h1 class="h2">
        <span class="visually-hidden">{{ 'general.search.heading' | t: count: search.results_count }}:</span>
        {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
      </h1>
  {% endif %}
      <div class="grid">
        <div class="grid__item medium-up--two-fifths medium-up--push-three-tenths">
          <form action="{{ routes.search_url }}" method="get" role="search" class="search">
            <input type=hidden name=type value="product">
            <div aria-live="polite" class="form-message form-message--error search-result-error-message hide" data-search-error-message>
              <ul id="error-search-form">
                <li>{{ 'general.search.empty_search_message' | t }}</li>
              </ul>
            </div>
            <div class="input-group">
              <input type="search"
                id="SearchInput"
                class="input-group__field search__input"
                name="q"
                value="{{ search.terms | escape }}"
                placeholder="{{ 'general.search.placeholder' | t }}"
                aria-label="{{ 'general.search.placeholder' | t }}"
                >
              <span class="input-group__btn">
                <button id="SearchResultSubmit" class="btn search__submit" type="submit">{{ 'general.search.submit' | t }}</button>
              </span>
            </div>
          </form>
        </div>
      </div>
      {% if search.performed and search.results_count == 0 %}
        <hr class="hr--small hr--invisible" aria-hidden="true" />
        <div class="rte">
          <p>{{ 'No results were found, please try another search.'}}</p>
        </div>
      {% endif %}
  </div>
</div>
{% if search.performed %}
  {% if search.results_count > 0 %}
    <hr aria-hidden="true" />
  {% endif %}
  <h2 class="visually-hidden">{{ 'general.search.heading' | t: count: search.results_count }}</h2>
  <ul class="page-width grid">
    {% for item in search.results %}
      <li class="grid__item one-quarter">
          {% if item.object_type == 'product' %}
            {% include 'product-card-grid', product: item %}
          {% else %}
            <div class="product-card product-card--grid">
              <a href="{{ item.url }}" class="full-width-link">
                <span class="visually-hidden">{{ item.title }}</span>
              </a>
              <div class="grid-view-item__link">
                {% if item.image %}
                  <div class="grid-view-item">
                    <div style="max-width: none !important" class="grid-view-item__image-wrapper product-card__image-wrapper">
                      <img style="max-width: none !important" class="grid-view-item__image" src="{{ item.image.src | img_url: '600x600' }}" alt="{{ item.image.alt | escape }}">
                    </div>
                  </div>
                {% endif %}
                <div class="grid-view-item__title-column">
                  <div class="grid-view-item__title" aria-hidden="true">
                    <span class="product-card__title">{{ item.title }}</span>
                  </div>
                  <div>
                    {% if item.published_at %}{{ item.published_at | date: format: "date" }} &#8212; {% endif %}
                    {{ item.content | strip_html | truncate: 200 }}
                  </div>
                </div>
              </div>
            </div>
          {% endif %}
      </li>
    {% endfor %}
  </ul>
  {% if paginate.pages > 1 %}
    {% include 'pagination' %}
  {% endif %}
{% endif %}
{% endpaginate %}
Replies 2 (2)
medlingtonQPS
Excursionist
16 0 3

Hi,

I think the problem youve got is that the name of your Gordon train toy is shorter than the others so the overall height of that box is smaller than the others on that line, as the items are in divs that are floated next to each other its making the next div to be floated position itself just under the gordon item as there is space there for it.

A couple of solutions:

1. Easiest is to just add a few words to the name of your Gordon item so it goes onto 2 lines like your other products. This would be a quick fix but not ideal as it may affect other items.

2. You could force the overall height of the div to be a certain height which would account for the different heights of the names. Try something like this in your CSS:

.grid__item {height:366px}

  Might be better to use vw as the units and then it would be responsive tothe window widdth too.

3. Another way to do it would be to add some java to check the heights of all the elements with the class name of .grid_item and then set all the heights to the height of the tallest element. Sorry Ive not got time to do the java for you but if your still stuck I could add it later.

4. Another way would be to add a counter within the liquid file which increments each time an item is added, once the counter hits 4 then echo a div with the style of clear:both which would in effect create a break between each line. This would only be usefull if you always have 4 per row and youve have to change it manually if there were a different number per row

 

LitExtension
Shopify Partner
1952 323 394

Hi @PastorClez,

Please follow these steps:

- Step 1: Go to Online store > Themes > Actions > Edit code.

- Step 2: Go to Assets > theme.css and paste this at the bottom of the file:

.template-search .main-content .page-width.grid {
display: flex !important;
flex-wrap: wrap !important;
}

Hope it helps!

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!