Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 样式底部PostWordPress_Css_Wordpress Theming_Wordpress - Fatal编程技术网

Css 样式底部PostWordPress

Css 样式底部PostWordPress,css,wordpress-theming,wordpress,Css,Wordpress Theming,Wordpress,如何将类“bottompost”添加到我的wordpress blogroll底部的帖子中?我需要改变它的风格。(我不能使用静态ID,因为帖子和帖子总数不断变化)您可以使用CSS伪类:last child来选择最后一篇帖子 例如: 将我链接到您的博客,我将能够给出一个工作示例。您可以使用jQuery向元素添加类: $(".post:last-child").addClass("bottom-post"); 然后这样做: .bottom-post { /* Different styli

如何将类“bottompost”添加到我的wordpress blogroll底部的帖子中?我需要改变它的风格。(我不能使用静态ID,因为帖子和帖子总数不断变化)

您可以使用CSS伪类
:last child
来选择最后一篇帖子

例如:


将我链接到您的博客,我将能够给出一个工作示例。

您可以使用jQuery向元素添加类:

$(".post:last-child").addClass("bottom-post");
然后这样做:

.bottom-post {
    /* Different styling */
}
这种方法的一个好处(与使用纯css相比)是,它将类应用于元素,并允许在不支持
:last child
css选择器的浏览器上进行样式设置。我在IE6-8上测试了这个,它在所有的IE6-8上都有效

以下解释了为什么在这种情况下,首选
:last child
psuedo选择器而不是
:last

.bottom-post {
    /* Different styling */
}