I am trying to get a fade on the post content, just like the title. See image. 
However, I can't manage to make it sit in between the top and bottom border.Here is the code.
This is the post Message container.
.PostMessage{
max-height: 6em;
overflow:hidden;
border-top: 1px solid black;
border-bottom: 1px solid black;
padding: 10px;
}
Here is the fading.
.PostMessage::before{
position:absolute;
content: '';
background: linear-gradient(to right, transparent 93%, red 99%);
width: calc(100% - 61px);
max-width: 728px;
height: 97px;
pointer-events: none;
}
Here is the html:
<div class="PostContainer">
<div class="PostContainerMetadata">
<p class="PostContainerMetadataID">Post id # <a href="">23</a></p>
<p class="PostContainerMetadataInfo"> <a href="">Videogames</a> • Posted by <a href="">user</a> on xx-xx-xx</p>
</div>
<div class="PostTitle">
<h2>Title of post</h2>
</div>
<div class="PostMessage"><pre><code>This is a short message.</code></pre></div>
</div>
TL;DR. Replace fixed height with a flexible one. (See code snippet)
As noted in the comment,
.PostMessagehas a flexible height with amax-heightof6emwhereas its::beforepseudo-element has a static height of97px, which makes the::beforetaller than the element itself.You can add
position: relativeto the main.PostMessageelement, and usetop: 0;andbottom: 0;for its::beforepseudo-elements, and removeheightof it.