I have a set of cards that display an image either on the left or right side, depending on whether it's an odd or even numbered card. On smaller screens, only the even numbered cards show the image at the top, while the odd numbered cards hide the image.
The code snippet demonstrates this behavior. When viewing in full screen, all four images are visible, but upon reducing the viewport size, only the images of the even numbered cards move to the top.
I am having trouble identifying the cause of this issue, but I suspect it has something to do with my use of the :nth-of-type() CSS pseudo-class. Any suggestions on how to correct this?
Kind regards
.blog-card {
display: flex;
flex-direction: column;
margin: 1rem auto;
box-shadow: 0 2px 6px -1px rgba(0, 0, 0, .07), 0 6px 18px -1px rgba(0, 0, 0, .04);
margin-bottom: 1.6%;
background: #fff;
line-height: 1.5;
border-radius: 0;
overflow: hidden;
z-index: 0;
}
.blog-card:nth-of-type(odd) {
flex-direction: row-reverse;
}
.blog-card:nth-of-type(odd) .description:before {
left: inherit;
right: -10px;
transform: skew(3deg);
}
.blog-card:hover .photo {
transform: scale(1.1) rotate(3deg);
}
.blog-card .meta {
position: relative;
z-index: 0;
height: 200px;
}
/* Additional styling rules... */
@media (min-width: 640px) {
/* Responsive styling for larger viewports */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9dfff2f2e9eee9effceddda9b3aeb3ac">[email protected]</a>/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.usebootstrap.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<h2>Cards</h2>
<hr>
<!-- Card HTML structure with meta and description sections -->