【发布时间】:2020-11-27 17:18:24
【问题描述】:
所以,我有一个 div flex,它使用 Custom Fields 和 Twig 从 wordpress 获取 3 个帖子。
我得到图像、标题,然后将它们显示在 div 中,一切都很好。现在我想做下面的例子,当鼠标移到图像上时,图像会逐渐失去它的向下部分,并且会显示标题以及发布顺序。我尝试了鼠标悬停、悬停和其他东西,但我无法让它工作。所以先看看,这是朋友做的模型:
这是我想做的,我的项目就是这样,不同的是标题在图片下面,顺序(01、02、03)没有显示。在此处检查当前状态:
这是用于从 wordpress 获取帖子的代码
/* Main file code : */
{% for post in homeserviceposts %}
{% include 'category.twig' %}
{% endfor %}
/* Imported file code: */
{% block content %}
<a title="{{post.title}}" href="{{post.link}}">
{% if post.thumbnail.src %}<img class="img-responsive post-image" src="{{post.thumbnail.src}}"/> {% endif %}
<h2 class="post-title">{{post.title}}</h2>
</a> {% endblock %}
基本上就是这样,我感谢所有愿意花时间教我新东西的人!
【问题讨论】:
-
使用 CSS 还是 JS?能否请您发布您的完整代码?
-
我在这个项目中使用 CSS,我的查询代码在 CSS 中如下所示,HTML 已经给出,仅此而已。
.flex-container-posts { display: flex; justify-content: end; flex-direction: row; height: 845px; } .flex-container-posts a { width: 380px; text-align: center; } .field-article1 { height: 900px; } .img-responsive { width: 405px; height: 536px; padding: 0 10px; margin-top: 152px; }
标签: html css wordpress web twig