2

I'm working on a my personal blog but facing some alignment issues.

I would need to get the "Read more" buttons aligned to the bottom.

Basically, the title should never be clipped but more or less lines of article preview should be shown accordingly. So far, I can get those buttons aligned but only by clipping the title to one line.

enter image description here

Here is a snippet of the code that handles that:


.article__tags {
  margin-bottom: $section-spacing / 2;
}

.article__tags--list {
  font-style: italic;
}

.article__link {

  display: block;

  @include media-query($small) {
    @include display-flexbox;
    @include flex-direction(column);
  }

  &:not([disabled]):hover,
  &:focus {
    .article__grid-image-wrapper {
      @include overlay(1);
    }
  }

}

.article__link--fixed-overlay {
  &:not([disabled]):hover,
  &:focus {
    .article__grid-image-wrapper::before {
      bottom: auto;
    }
  }
}

 /* This should be the button I'm struggling with */
.article__meta-buttons {
  li {
    &:first-child {
      margin-right: 1.5rem;
    }
  }
}

.article__comment-count {
  border-color: transparent;
  border-bottom-color: currentColor;
  padding: 0 0 3px 0;

  &:not([disabled]):hover,
  &:focus {
    border-color: transparent;
    border-bottom-color: currentColor;
  }
}

.rte--article {
  margin-bottom: 20px;
}

.grid--blog {
  margin-bottom: -$section-spacing;
  overflow: auto;
    
    /**Major Properties**/
  overflow:hidden;
  line-height: 1.7rem;
  display: block;
  overflow: hidden !important;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
}

.article__grid-tag {
  margin-right: 10px;
}

.article__grid-meta {
  margin-bottom: $section-spacing;
}

@include media-query($small) {
  .article__grid-meta--has-image {
    float: left;
    padding-left: $gutter-site-mobile;
  }
}

.article__grid-excerpt {
  margin-bottom: $section-spacing-small / 2;
  
  /**Major Properties**/
  overflow:hidden;
  line-height: 1.7rem;
  max-height: 8rem;
  -webkit-box-orient: vertical;
  display: block;
  display: -webkit-box;
  overflow: hidden !important;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
}

.article__titles {
  margin-bottom: $section-spacing-small / 2;
  
  /**Major Properties**/
  overflow:hidden;
  line-height: 1.7rem;
  max-height: 8rem;
  -webkit-box-orient: vertical;
  display: block;
  display: -webkit-box;
  overflow: hidden !important;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
}

.article-image-wrapper {
  &.article__grid-image-wrapper {
    margin-left: 0;
    margin-right: 0;
  }
}

.article__grid-image-wrapper {
  margin: 0 auto;
  position: relative;
  width: 100%;
}

.article__grid-image-wrapper--small {
  width: 50%;
}

.article__grid-image-container {
  display: block;
  clear: both;
  position: relative;

  margin: 0 auto $section-spacing / 2 0;
  min-height: 1px;
  width: 100%;
  height: 100%;

  @include media-query($small) {
    float: left;
    margin: 0 0 $section-spacing 0;
  }


  img {
    display: block;
  }
}

.article__grid-image {
  margin: 0 auto;
  width: 100%;

  .js & {
    position: absolute;
    top: 0;
  }
}

.article__list-image-container {
  display: block;
  clear: both;
  position: relative;
  min-height: 1px;
  width: 100%;
  height: 100%;
}

.article__list-image-wrapper {
  width: 100%;
  margin-bottom: 20px;
}

.article__list-image {
  margin: 0 auto;
  width: 100%;
  position: absolute;
  top: 0;
}

Dodo
  • 31
  • 4
  • 1
    Post your HTML too. We need a [mcve] – j08691 Sep 16 '22 at 15:49
  • Thank you for the reply, in an ideal case I would also like to have the article preview that finishes at the same point for all the articles. My ideas for the moment would be to set for example the article preview to: 3 lines of article preview in case the title is 4 lines long, 4 lines of text in case the title is 3 lines long, – Dodo Sep 17 '22 at 20:38
  • 5 lines of text in case the title is 2 lines long and 6 lines of text in case the article is only long 1 line. The alternative way that came to mind is to set a maximum height for the title + article preview combo and set an overflow for the extra text. I still haven't found an effective way to implement one or the other idea though. – Dodo Sep 17 '22 at 20:38

1 Answers1

0

You can use flex-box. When a container's direction is set to column by flex-direction: column; the last child can be align at the bottom by setting margin-top: auto;. In case where you want to align an item at the end of a row flex, you can use margin-left and set it to auto. Here is a small snippet for that:

.container {
    display: flex
}

.column {
    display: flex;
    flex-direction: column;
    width: 30vw;
    margin: 0 1vw
}

.button {
    margin-top: auto;
}

img {
    width: 100%;
}
h4, p {
    margin: 1vw 0
}
<div class="container">
    <div class="column">
        <div class="image"> <img src="https://placekitten.com/100/100" /> </div>
        <h4>
It is a long established fact that a reader will be
  </h4>
        <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled </p>
        <div class="button">
            <button>Read More</button>
        </div>
    </div>
    <div class="column">
        <div class="image"> <img src="https://placekitten.com/200/200" /> </div>
        <h4>
  It is a long established 
  </h4>
        <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's stand </p>
        <div class="button">
            <button>Read More</button>
        </div>
    </div>
    <div class="column">
        <div class="image"> <img src="https://placekitten.com/250/250" /> </div>
        <h4>
  It is a long established fact that a reader
  </h4>
        <p> Lorem Ipsum is simply dummy text of the printing </p>
        <div class="button">
            <button>Read More</button>
        </div>
    </div>
</div>
BehRouz
  • 1,209
  • 1
  • 8
  • 17
  • Thank you @BehRouz, I see that your snippet does exactly what I am looking for. Unfortunately, I cant make my code working even having seen your source. This is my scss code . I am editing the code in the top post such to add more details, may be you can spot what I am doing wrong – Dodo Sep 19 '22 at 20:34
  • Could you make a snippet too? That way I can see the HTML too. I'll try to help you with that. – BehRouz Sep 19 '22 at 23:39