Magento 2.2.1 Ultimo主题Magefan博客最新文章列表样式修复求助
Fix Misaligned Blog Posts Widget in Magento 2 (Magefan Blog Extension)
Hey there, let's get that homepage blog widget sorted out! Your approach to overriding the extension's CSS in your theme directory is spot-on—this is the correct Magento 2 way to customize extension styles without modifying core files.
Here's the CSS code you can add to your public_html/app/design/frontend/Infortis/ultimo/web/css/blog-custom.css file to fix the height inconsistency and alignment issue:
/* Target the Magefan blog posts widget container */ .mf-blog-posts-widget .post-list { display: flex; flex-wrap: wrap; margin: 0 -15px; /* Offset padding on items to avoid extra container width */ } /* Style each individual blog post item to enforce 3 per row */ .mf-blog-posts-widget .post-list .post-item { flex: 0 0 33.333%; /* Lock each item to 1/3 of the container width */ max-width: 33.333%; box-sizing: border-box; padding: 0 15px; margin-bottom: 25px; /* Add spacing between rows for readability */ } /* Ensure post cards fill the full height of their column */ .mf-blog-posts-widget .post-item .post-holder { height: 100%; display: flex; flex-direction: column; } /* Optional: Push the "read more" button to the bottom of each card for uniform layout */ .mf-blog-posts-widget .post-item .post-read-more { margin-top: auto; }
What this code does:
- Uses flexbox to guarantee consistent row alignment and proper wrapping of post items
- Locks exactly 3 posts per row with
33.333%width (adjust this value if you want more/less items per row later) - Forces each post card to take up the full height of its column, eliminating height mismatches caused by varying content lengths
- Adds padding and margin for clean spacing without breaking the container layout
- (Optional) Pushes the "read more" button to the bottom of every card for a polished, uniform look
Quick tips:
- If the class names don't match your site's actual elements, right-click on the misaligned posts in your browser and select "Inspect" to find the correct CSS selectors.
- After adding the code, clear your Magento cache with
bin/magento cache:flushand your browser cache to see the changes take effect.
内容的提问来源于stack exchange,提问作者Jhon
相关产品推荐
相关产品推荐

