Wordpress 使用CSS仅调整文章中的第一个图像大小,而不影响任何其他图像

Wordpress 使用CSS仅调整文章中的第一个图像大小,而不影响任何其他图像,wordpress,css,Wordpress,Css,如何在不影响文章中任何其他图像的情况下,使用CSS仅调整文章中出现的第一个图像的大小。如果我使用以下代码: #content div.single:nth-of-type(n) img { width: 448px !important; height: 252px !important; padding: 0 !important; margin-top: 0; 它会调整文章中显示的所有图像的大小 我还尝试了第N个孩子,但没有成功: #content div.single img:nth-c

如何在不影响文章中任何其他图像的情况下,使用CSS仅调整文章中出现的第一个图像的大小。如果我使用以下代码:

#content div.single:nth-of-type(n) img {
width: 448px !important;
height: 252px !important;
padding: 0 !important;
margin-top: 0;
它会调整文章中显示的所有图像的大小

我还尝试了第N个孩子,但没有成功:

#content div.single img:nth-child(1){
width: 448px !important;
height: 252px !important;
padding: 0 !important;
margin-top: 0;}

下面是

为什么不像这样瞄准你想要的图像:

.alignnone.size-full.wp-image-35095 {
width: 448px !important;
height: 252px !important;
padding: 0 !important;
margin-top: 0;
}
.single p:nth-child(2) > img {
width: 448px !important;
height: 252px !important;
padding: 0 !important;
margin-top: 0;
}
当你有一个带有空格的类时,你的目标是css中的类,但是你用一个点来改变每个空格

如果希望始终以帖子中的第一个图像为目标,则可以运行Jquery:

$( "#content img" ).first().attr('width', '150');
顺便说一句,你的第一张图片中有一个重要的信息,我一直在努力解释为什么这不起作用:p

你可以试试这个:

#content div.single img:first-child {
 width: 448px !important;
 height: 252px !important;      
 padding: 0 !important;
 margin-top: 0;
}

使用CSS轻松解决此问题,如下所示:

.alignnone.size-full.wp-image-35095 {
width: 448px !important;
height: 252px !important;
padding: 0 !important;
margin-top: 0;
}
.single p:nth-child(2) > img {
width: 448px !important;
height: 252px !important;
padding: 0 !important;
margin-top: 0;
}

他希望每一个职位。如果你这样做,那只是针对一篇特定的文章,这是错误的。你现在批准了吗?
:第一个孩子
伪选择器应该可以工作…顺便说一句,你在该页面上的每篇文章只有一个图像,因此你在该页面上的文章中的所有图像都会受到影响-如果你确实针对每篇文章中的第一个图像。。。您是指页面上第一篇文章中的第一张图片吗?您想更改GTA徽标吗?