【发布时间】:2016-06-02 07:39:59
【问题描述】:
我正在尝试将我的特色图片设置为 CSS 中的背景图片。
我需要在 HTML 和 CSS 的两个地方显示相同的特色图片。
如何在 CSS 中使用the_post_thumbnail()?
HTML
<div class="magnify">
<div class="large"></div>
<img class="small" <?php the_post_thumbnail( 'large', array
('class' =>'img- responsive') ); ?> />
</div>
CSS
.large {background: url('img/image.jpg') no-repeat;}
【问题讨论】:
-
您需要为此使用内联 CSS - 例如在您的 HTML 元素上使用
style="background-image: ......."- 因为您无法将 PHP 值放入 CSS。 -
请用 wordpress 查询完成代码