WordPress 自定义博客页面

发布于 2025-01-09 15:38:52 字数 349 浏览 2 评论 0原文

我想要自定义 WordPress 博客页面,就像照片中的页面一样。我尝试根据文章的年龄将文章放置为不同的布局,即最后一篇文章具有最大的缩略图,接下来的两篇文章具有第二大的缩略图,其余的文章具有最小的缩略图。 这是启发我的网站

您知道是否有办法实现这一目标?

其余网站使用 elementor pro 和 crockblock。 主题:你好

I want to customize the WordPress blog page like the one in the photo. I try to put the articles to have a different layout depending on their age, ie the last article to have the largest thumbnail, the next 2 to have the second-largest thumbnail, and the rest to have the smallest thumbnail.
This is the site that inspired me.

Do you know if there is a way to achieve this?

Am using elementor pro and crockblock for the rest website.
Theme: Hello

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿挽旧人 2025-01-16 15:38:52

纯 CSS 解决方案。

.grid {
  width: 100%;
  display: grid; 
  grid-auto-flow: row; 
  grid-auto-rows: 1fr; 
  grid-template-columns: 1fr 1fr; 
  grid-template-rows: auto auto; 
  gap: 32px; 
  justify-items: stretch; 
 }
  
  .item {
    /* All items */
    background-color: gray;
    width: 100%;
    height: 100%;
    grid-column: span 2;
  }
  
  .item:nth-child(1) {
      /* First item */
      background-color: red;
  }
  
  .item:nth-child(2), .item:nth-child(3) {
      /* second and third */
      background-color: blue;
      grid-column: span 1;
  }
  
  .item:nth-child(n+4) {
    /* Every item after the 3rd */
    background-color: green;
  }
<div class="grid">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
  <div class="item">5</div>
  <div class="item">6</div>
  <div class="item">7</div>
  <div class="item">8</div>
  <div class="item">9</div>
  <div class="item">10</div>
</div>

只要您不需要中间的其他随机内容,这就是最优雅、最直接的解决方案。我保证这一点的主要原因是现有主题代码并不复杂。基本上可以添加到 Wordpress 中的 CSS 定制器中。

A pure CSS solution.

.grid {
  width: 100%;
  display: grid; 
  grid-auto-flow: row; 
  grid-auto-rows: 1fr; 
  grid-template-columns: 1fr 1fr; 
  grid-template-rows: auto auto; 
  gap: 32px; 
  justify-items: stretch; 
 }
  
  .item {
    /* All items */
    background-color: gray;
    width: 100%;
    height: 100%;
    grid-column: span 2;
  }
  
  .item:nth-child(1) {
      /* First item */
      background-color: red;
  }
  
  .item:nth-child(2), .item:nth-child(3) {
      /* second and third */
      background-color: blue;
      grid-column: span 1;
  }
  
  .item:nth-child(n+4) {
    /* Every item after the 3rd */
    background-color: green;
  }
<div class="grid">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
  <div class="item">5</div>
  <div class="item">6</div>
  <div class="item">7</div>
  <div class="item">8</div>
  <div class="item">9</div>
  <div class="item">10</div>
</div>

As long as you don't need other random content in between, this is the most elegant and straight forward solution. The main reason i vouch for this, is that there is no complication of the existing theme code. And could basically just be added to the CSS Customizer in Wordpress.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文