如何使用<Picture class=“c-Picture”>将所有博客帖子图片包装起来

时间:2021-07-20 作者:Godwin

优秀的WordPress程序员,我想用我的WordPress主题解决一个图像问题。我尽我所能,但找不到解决办法。

问题是我添加的博客帖子图像没有响应。而我的功能图像是响应的,因为它有标签<picture class="c-picture">. 如果我添加<picture class="c-picture"> 手动给它的图像,修复它。

示例:

<picture class="c-picture"><img loading="lazy" class="alignnone wp-image-160 size-full" src="https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=2048%2C2048&amp;ssl=1" alt="" width="2048" height="2048" srcset="https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?w=2048&amp;ssl=1 2048w, https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=300%2C300&amp;ssl=1 300w, https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=150%2C150&amp;ssl=1 150w, https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=768%2C768&amp;ssl=1 768w, https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=1536%2C1536&amp;ssl=1 1536w, https://i1.wp.com/sololoaded.com/wp-content/uploads/2021/06/20210617_164346.jpg?resize=1568%2C1568&amp;ssl=1 1568w" sizes="(max-width: 1000px) 100vw, 1000px" data-recalc-dims="1"></picture>
我的问题是,我能有一个<picture class="c-picture"> 到所有博客帖子图像。谢谢各位。帖子链接:https://sololoaded.com/nigerian-music-artists-who-were-born-rich/

1 个回复
最合适的回答,由SO网友:Mafnah 整理而成

我认为在您的情况下,您可以通过添加height: auto; 到图像标记:

.c-entry-content img {
    max-width: 100%;
    height: auto;
}