This is what my code looks like. I’m looping through each post to make it show up on my website.
<div class="blog-container">
<div class="posts">
{% for post in site.posts %}
<div class="post-preview">
<h2 class="post-title hover-underline-animation"><a href="{{ post.url }}" class="blue">{{ post.title }}</a></h2>
<p class="post-date">{{ post.date | date: "%B %d, %Y" }}</p>
<div class="post-summary">
{{ post.summary | strip_html }}
</div>
</div>
{% endfor %}
</div>
</div>
This is what the output currently looks like:
This is what I’d like the posts to look like:
I’m not sure how to make the spacing how I want it to be, while remaining constant when I resize the page. I’m a complete beginner trying to use Jekyll. All help is greatly appreciated!
3
Answers
You can play around with
padding
andmargin
to achieve your result. I have below code which uses pure HTML and CSS but inJekyll
also you’ll be able to attach style tag to your pages and achieve the same result.You ca use the below code for reference.
Hope this helps
I don’t know how your CSS classes are setup, but you can easily achive it by adding:
padding-top: 16px
andpadding-bottom: 16px
(adjust thepx
value as you please) to yourpost-preview
class.Try this:
*Just go through the CSS box model