How to make every post equal in size when responding to screen size

Inside the post div, there will be multiple post rows. Each row contains maximum 4 posts. So when there are 5 posts there comes the problem with responsiveness. First 4 posts (first row) will respond to the screen size but the 5th post (second row) does nothing because there are space left for the 5th post.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><div class="posts">
{% if post %}
{% for media in post %}
{% if forloop.counter0|divisibleby:"4" %}
<div class="post-row">
{% endif %}
<a id="post-wrapper" href="{% url 'sh-media' %}?pid={{media.pid}}">
<div class="thumbnail-container">
<img src="{{ media.media_thumbnail.url }}" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">{{ media.caption}}</h2>
<p class="video-description">{{ media.descr }}</p>
</div>
</div>
</a>
{% if forloop.counter0|add:"1"|divisibleby:"4" or forloop.last %}
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>
<style>
.posts{
display: flex;
flex-direction: column;
color: #fff;
padding-top: 15px;
justify-content: flex-start;
}
.post-row{
display: flex:
}
#post-wrapper{
margin: 20px 10px;
}
</style>
</code>
<code><div class="posts"> {% if post %} {% for media in post %} {% if forloop.counter0|divisibleby:"4" %} <div class="post-row"> {% endif %} <a id="post-wrapper" href="{% url 'sh-media' %}?pid={{media.pid}}"> <div class="thumbnail-container"> <img src="{{ media.media_thumbnail.url }}" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">{{ media.caption}}</h2> <p class="video-description">{{ media.descr }}</p> </div> </div> </a> {% if forloop.counter0|add:"1"|divisibleby:"4" or forloop.last %} </div> {% endif %} {% endfor %} {% endif %} </div> <style> .posts{ display: flex; flex-direction: column; color: #fff; padding-top: 15px; justify-content: flex-start; } .post-row{ display: flex: } #post-wrapper{ margin: 20px 10px; } </style> </code>
<div class="posts">
    {% if post %}
        {% for media in post %}
            {% if forloop.counter0|divisibleby:"4" %}
                <div class="post-row">
            {% endif %}
            <a id="post-wrapper" href="{% url 'sh-media' %}?pid={{media.pid}}">
                <div class="thumbnail-container">
                    <img src="{{ media.media_thumbnail.url }}" class="post-thumbnail">
                    <div class="gradient-overlay">
                        <h2 class="video-caption">{{ media.caption}}</h2>
                        <p class="video-description">{{ media.descr }}</p>
                    </div>
                </div>
            </a>
            {% if forloop.counter0|add:"1"|divisibleby:"4" or forloop.last %}
                </div>
            {% endif %}
        {% endfor %}
    {% endif %}
</div>

<style>
    .posts{ 
        display: flex;
        flex-direction: column;
        color: #fff;
        padding-top: 15px;
        justify-content: flex-start;
    }
    .post-row{
        display: flex:
    }
    #post-wrapper{
        margin: 20px 10px;
    }
</style>

Is there any way to make all the posts will maintain the same size when it respond to the screen size?

Output HTML:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
<div class="posts">
<div class="post-row">
<a id="post-wrapper" href="/watch-profile%23ed-media?pid=060">
<div class="thumbnail-container">
<img src="/static/images/9_16%20Video.png" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">sea breeze</h2>
<p class="video-description">Winter morning sweet music</p>
</div>
</div>
</a>
<a id="post-wrapper" href="/watch-profile%23ed-media?pid=bea">
<div class="thumbnail-container">
<img src="/static/images/9_16%20Audio.png" class="post-thumbnail" >
<div class="gradient-overlay">
<h2 class="video-caption">Winter</h2>
<p class="video-description">Winter morning sweet music</p>
</div>
</div>
</a>
<a id="post-wrapper" href="/watch-profile%23ed-media?pid=ba8">
<div class="thumbnail-container">
<img src="/media/media/Thumbnails/DSC_0354.JPEG" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">Thousand years</h2>
<p class="video-description">A Thousand Years, a romantic song about the fear of falling in love, is a sleeper hit.</p>
</div>
</div>
</a>
<a id="post-wrapper" href="/watch-profile%23ed-media?pid=731">
<div class="thumbnail-container">
<img src="/media/media/Thumbnails/martin-blaszkiewicz-fv8YJZ471kQ-unsplash.jpg" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">Aurora Runaway</h2>
<p class="video-description">a song by Norwegian singer-songwriter Aurora</p>
</div>
</div>
</a>
</div>
<div class="post-row">
<a id="post-wrapper" href="/watch-profile%23ed-media?pid=46e">
<div class="thumbnail-container">
<img src="/media/media/Thumbnails/_c5eea445-cb7b-4aaa-8a8c-74a43e3c6561-transformed.jpeg" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">KungFu Panda</h2>
<p class="video-description">4k video of kungfu panda</p>
</div>
</div>
</a>
</div>
</div>
</code>
<code> <div class="posts"> <div class="post-row"> <a id="post-wrapper" href="/watch-profile%23ed-media?pid=060"> <div class="thumbnail-container"> <img src="/static/images/9_16%20Video.png" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">sea breeze</h2> <p class="video-description">Winter morning sweet music</p> </div> </div> </a> <a id="post-wrapper" href="/watch-profile%23ed-media?pid=bea"> <div class="thumbnail-container"> <img src="/static/images/9_16%20Audio.png" class="post-thumbnail" > <div class="gradient-overlay"> <h2 class="video-caption">Winter</h2> <p class="video-description">Winter morning sweet music</p> </div> </div> </a> <a id="post-wrapper" href="/watch-profile%23ed-media?pid=ba8"> <div class="thumbnail-container"> <img src="/media/media/Thumbnails/DSC_0354.JPEG" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">Thousand years</h2> <p class="video-description">A Thousand Years, a romantic song about the fear of falling in love, is a sleeper hit.</p> </div> </div> </a> <a id="post-wrapper" href="/watch-profile%23ed-media?pid=731"> <div class="thumbnail-container"> <img src="/media/media/Thumbnails/martin-blaszkiewicz-fv8YJZ471kQ-unsplash.jpg" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">Aurora Runaway</h2> <p class="video-description">a song by Norwegian singer-songwriter Aurora</p> </div> </div> </a> </div> <div class="post-row"> <a id="post-wrapper" href="/watch-profile%23ed-media?pid=46e"> <div class="thumbnail-container"> <img src="/media/media/Thumbnails/_c5eea445-cb7b-4aaa-8a8c-74a43e3c6561-transformed.jpeg" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">KungFu Panda</h2> <p class="video-description">4k video of kungfu panda</p> </div> </div> </a> </div> </div> </code>

<div class="posts">
    <div class="post-row">
                        
        <a id="post-wrapper" href="/watch-profile%23ed-media?pid=060">
            <div class="thumbnail-container">
                <img src="/static/images/9_16%20Video.png" class="post-thumbnail">
                <div class="gradient-overlay">
                    
                        <h2 class="video-caption">sea breeze</h2>
                        <p class="video-description">Winter morning sweet music</p>
                    
                </div>
            </div>
        </a>
        
    
        
        <a id="post-wrapper" href="/watch-profile%23ed-media?pid=bea">
            <div class="thumbnail-container">
                <img src="/static/images/9_16%20Audio.png" class="post-thumbnail" >
                <div class="gradient-overlay">
                    
                        <h2 class="video-caption">Winter</h2>
                        <p class="video-description">Winter morning sweet music</p>
                    
                </div>
            </div>
        </a>
        
    
        
        <a id="post-wrapper" href="/watch-profile%23ed-media?pid=ba8">
            <div class="thumbnail-container">
                <img src="/media/media/Thumbnails/DSC_0354.JPEG" class="post-thumbnail">
                <div class="gradient-overlay">
                    
                        <h2 class="video-caption">Thousand years</h2>
                        <p class="video-description">A Thousand Years, a romantic song about the fear of falling in love, is a sleeper hit.</p>
                
                </div>
            </div>
        </a>
        
    
        
        <a id="post-wrapper" href="/watch-profile%23ed-media?pid=731">
            <div class="thumbnail-container">
                <img src="/media/media/Thumbnails/martin-blaszkiewicz-fv8YJZ471kQ-unsplash.jpg" class="post-thumbnail">
                <div class="gradient-overlay">
                    
                        <h2 class="video-caption">Aurora Runaway</h2>
                        <p class="video-description">a song by Norwegian singer-songwriter Aurora</p>
                
                </div>
            </div>
        </a>
                        
    </div>
                        
    <div class="post-row">
                        
        <a id="post-wrapper" href="/watch-profile%23ed-media?pid=46e">
            <div class="thumbnail-container">
                <img src="/media/media/Thumbnails/_c5eea445-cb7b-4aaa-8a8c-74a43e3c6561-transformed.jpeg" class="post-thumbnail">
                <div class="gradient-overlay">
                    
                        <h2 class="video-caption">KungFu Panda</h2>
                        <p class="video-description">4k video of kungfu panda</p>
                
                </div>
            </div>
        </a>
                        
    </div>
                        
                    
                
</div>

New contributor

Benet Paul Benny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

You have a typo in .post-row {display: flex:} so we correct that. Then set the flex value of the links to flex: 0 0 25% so they are each 1/4 of the width

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>* {
margin: 0;
padding: 0;
min-width: 0;
min-height: 0;
box-sizing: border-box;
}
::before,
::after {
box-sizing: inherit;
}
.posts {
display: flex;
flex-direction: column;
color: #fff;
padding-top: 15px;
justify-content: flex-start;
}
.post-row {
display: flex;
margin-bottom: 10px;
}
.post-wrapper {
flex: 0 0 25%;
border: 1px solid red;
background: lightblue;
}
.post-wrapper:not(:last-child) {
margin-right: 10px;
}</code>
<code>* { margin: 0; padding: 0; min-width: 0; min-height: 0; box-sizing: border-box; } ::before, ::after { box-sizing: inherit; } .posts { display: flex; flex-direction: column; color: #fff; padding-top: 15px; justify-content: flex-start; } .post-row { display: flex; margin-bottom: 10px; } .post-wrapper { flex: 0 0 25%; border: 1px solid red; background: lightblue; } .post-wrapper:not(:last-child) { margin-right: 10px; }</code>
* {
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

::before,
::after {
  box-sizing: inherit;
}

.posts {
  display: flex;
  flex-direction: column;
  color: #fff;
  padding-top: 15px;
  justify-content: flex-start;
}

.post-row {
  display: flex;
  margin-bottom: 10px;
}

.post-wrapper {
  flex: 0 0 25%;
  border: 1px solid red;
  background: lightblue;
}

.post-wrapper:not(:last-child) {
  margin-right: 10px;
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><div class="posts">
<div class="post-row">
<a class="post-wrapper" href="/watch-profile%23ed-media?pid=060">
<div class="thumbnail-container">
<img src="/static/images/9_16%20Video.png" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">sea breeze</h2>
<p class="video-description">Winter morning sweet music</p>
</div>
</div>
</a>
<a class="post-wrapper" href="/watch-profile%23ed-media?pid=bea">
<div class="thumbnail-container">
<img src="/static/images/9_16%20Audio.png" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">Winter</h2>
<p class="video-description">Winter morning sweet music</p>
</div>
</div>
</a>
<a class="post-wrapper" href="/watch-profile%23ed-media?pid=ba8">
<div class="thumbnail-container">
<img src="/media/media/Thumbnails/DSC_0354.JPEG" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">Thousand years</h2>
<p class="video-description">A Thousand Years, a romantic song about the fear of falling in love, is a sleeper hit.</p>
</div>
</div>
</a>
<a class="post-wrapper" href="/watch-profile%23ed-media?pid=731">
<div class="thumbnail-container">
<img src="/media/media/Thumbnails/martin-blaszkiewicz-fv8YJZ471kQ-unsplash.jpg" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">Aurora Runaway</h2>
<p class="video-description">a song by Norwegian singer-songwriter Aurora</p>
</div>
</div>
</a>
</div>
<div class="post-row">
<a class="post-wrapper" href="/watch-profile%23ed-media?pid=46e">
<div class="thumbnail-container">
<img src="/media/media/Thumbnails/_c5eea445-cb7b-4aaa-8a8c-74a43e3c6561-transformed.jpeg" class="post-thumbnail">
<div class="gradient-overlay">
<h2 class="video-caption">KungFu Panda</h2>
<p class="video-description">4k video of kungfu panda</p>
</div>
</div>
</a>
</div>
</div></code>
<code><div class="posts"> <div class="post-row"> <a class="post-wrapper" href="/watch-profile%23ed-media?pid=060"> <div class="thumbnail-container"> <img src="/static/images/9_16%20Video.png" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">sea breeze</h2> <p class="video-description">Winter morning sweet music</p> </div> </div> </a> <a class="post-wrapper" href="/watch-profile%23ed-media?pid=bea"> <div class="thumbnail-container"> <img src="/static/images/9_16%20Audio.png" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">Winter</h2> <p class="video-description">Winter morning sweet music</p> </div> </div> </a> <a class="post-wrapper" href="/watch-profile%23ed-media?pid=ba8"> <div class="thumbnail-container"> <img src="/media/media/Thumbnails/DSC_0354.JPEG" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">Thousand years</h2> <p class="video-description">A Thousand Years, a romantic song about the fear of falling in love, is a sleeper hit.</p> </div> </div> </a> <a class="post-wrapper" href="/watch-profile%23ed-media?pid=731"> <div class="thumbnail-container"> <img src="/media/media/Thumbnails/martin-blaszkiewicz-fv8YJZ471kQ-unsplash.jpg" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">Aurora Runaway</h2> <p class="video-description">a song by Norwegian singer-songwriter Aurora</p> </div> </div> </a> </div> <div class="post-row"> <a class="post-wrapper" href="/watch-profile%23ed-media?pid=46e"> <div class="thumbnail-container"> <img src="/media/media/Thumbnails/_c5eea445-cb7b-4aaa-8a8c-74a43e3c6561-transformed.jpeg" class="post-thumbnail"> <div class="gradient-overlay"> <h2 class="video-caption">KungFu Panda</h2> <p class="video-description">4k video of kungfu panda</p> </div> </div> </a> </div> </div></code>
<div class="posts">
  <div class="post-row">

    <a class="post-wrapper" href="/watch-profile%23ed-media?pid=060">
      <div class="thumbnail-container">
        <img src="/static/images/9_16%20Video.png" class="post-thumbnail">
        <div class="gradient-overlay">

          <h2 class="video-caption">sea breeze</h2>
          <p class="video-description">Winter morning sweet music</p>

        </div>
      </div>
    </a>

    <a class="post-wrapper" href="/watch-profile%23ed-media?pid=bea">
      <div class="thumbnail-container">
        <img src="/static/images/9_16%20Audio.png" class="post-thumbnail">
        <div class="gradient-overlay">

          <h2 class="video-caption">Winter</h2>
          <p class="video-description">Winter morning sweet music</p>

        </div>
      </div>
    </a>

    <a class="post-wrapper" href="/watch-profile%23ed-media?pid=ba8">
      <div class="thumbnail-container">
        <img src="/media/media/Thumbnails/DSC_0354.JPEG" class="post-thumbnail">
        <div class="gradient-overlay">

          <h2 class="video-caption">Thousand years</h2>
          <p class="video-description">A Thousand Years, a romantic song about the fear of falling in love, is a sleeper hit.</p>

        </div>
      </div>
    </a>

    <a class="post-wrapper" href="/watch-profile%23ed-media?pid=731">
      <div class="thumbnail-container">
        <img src="/media/media/Thumbnails/martin-blaszkiewicz-fv8YJZ471kQ-unsplash.jpg" class="post-thumbnail">
        <div class="gradient-overlay">

          <h2 class="video-caption">Aurora Runaway</h2>
          <p class="video-description">a song by Norwegian singer-songwriter Aurora</p>

        </div>
      </div>
    </a>

  </div>

  <div class="post-row">

    <a class="post-wrapper" href="/watch-profile%23ed-media?pid=46e">
      <div class="thumbnail-container">
        <img src="/media/media/Thumbnails/_c5eea445-cb7b-4aaa-8a8c-74a43e3c6561-transformed.jpeg" class="post-thumbnail">
        <div class="gradient-overlay">

          <h2 class="video-caption">KungFu Panda</h2>
          <p class="video-description">4k video of kungfu panda</p>

        </div>
      </div>
    </a>

  </div>

</div>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật