Селектор CSS для предназначения только для непосредственных детей и не других идентичных потомков

Ваш код говорит: «Если боковой панели под названием« Виджет обзора Google »не существует, то ...» без чего-либо еще. Вы на самом деле не пытаетесь отобразить боковую панель, просто проверьте, существует ли она, а если нет, то отступите к ... ничему.

Просто используйте: <?php dynamic_sidebar( 'Google Review Widget' ); ?>, чтобы отобразить его.

62
задан the Tin Man 1 December 2016 в 17:40
поделиться

1 ответ

ul > li

only does the immediate children. So, for example, to do only the top level list elements you could use:

#parent > li

Note: this isn't supported on IE6.

The common workaround for backwards compatibility is to do something like this:

#parent li { /* style appropriately */ }
#parent li li { /* back to normal */ }

It's more tedious because you have to apply styles and then turn them off (and you may not necessarily know what the old values are) but it's the only IE6-friendly pure CSS workaround there is.

Edit: Ok you have a MooTools specific issue. getElements() returns all descendants, not just immediate children. Try using getChildren().

var drop = function(el){
    el.getParents('ul').reverse().each(function(item){
        var posCount = 1;
        item.getChildren("li").getElements("a span[class=position]").each(function(pos){
                pos.set('text', posCount);
                posCount++;
        });
    });
}

or something like that.

95
ответ дан 24 November 2019 в 16:50
поделиться
Другие вопросы по тегам:

Похожие вопросы: