【问题标题】:Wordpress - 3 Widgets in a sidebar, Apply "last" class to the third widgetWordpress - 侧边栏中的 3 个小部件,将“last”类应用于第三个小部件
【发布时间】:2012-04-27 02:15:28
【问题描述】:

我在我的 wordpress 网站中创建了一个自定义侧边栏

register_sidebar(array(
    'name' => 'Home Widgets',
    'before_widget' => '<div id="%1$s" class="blurb %2$s">',
    'after_widget' => '</div> <!-- end .widget -->',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
));

我已经使用管理页面中的小部件面板添加了 3 个小部件。

这是css

.blurb { float: left; margin-right: 96px; width: 256px; }

我还声明了一个“last”类来删除最后一个(第三个)小部件的边距。

.last { clear: right; margin-right: 0 !important; }

如何将“last”类应用到最后一个小部件?

【问题讨论】:

    标签: php css widget wordpress


    【解决方案1】:

    你不需要。将边距更改为margin-left 并创建一个类.blurb:first-child {margin-left: 0;},你应该没问题。 IE7+ 兼容。

    【讨论】:

    • 您使用伪类:first-child,因为:last-child 在IE7 中不具备可战斗性,我也相信8,但如果这不是问题,您可以使用:last-child
    • 要清除子项,您可以将父项对小部件的溢出更改为 auto 以外的其他内容,以清除其中的所有小部件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-03
    • 2020-04-22
    • 1970-01-01
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多