使用ul li时,在list上设置list-style-type:none

时间:2012-11-26 10:48:42

标签: html css

这是我的CSS

ul.xoxo.blogroll {      
    list-style-type: none;
    padding-left: 0px;
    margin-left: 27px;  
}
ul.xoxo.blogroll li img { 
    border: none;
    box-shadow: none;
}

现在我使用list-style-type: none;并且cicrcle不可见。但我希望当我使用ul li时,该圈子会显示,而当ul liimg代码时,该圈子不可见。

这可能吗?如果我设置

ul.xoxo.blogroll {
    padding-left: 0px;
    margin-left: 27px;  
}

ul.xoxo.blogroll li img { 
        list-style-type: none;
    border: none;
    box-shadow: none;
}

圈子无处不在。

3 个答案:

答案 0 :(得分:1)

AFAIK,特定孩子的父母没有CSS选择器。如果您只想使用CSS,则可以添加其他类,例如imglist或类似的,然后选择。

答案 1 :(得分:1)

如果我说得对,如果<img>内有<ul>,你希望list-type-stylenone,否则为circle

如果是这样,我认为您需要使用jQuery

<强> jQuery的:

​​$('ul.xoxo.blogroll img').each(function(){
    $(this).parent().css('listStyleType','none');
    });​​​​​​​​​​​​​​​​​​​​​​

脚本循环遍历每个<img>标记,并且.parent().css()它会操纵其父级的css属性,<li>将是什么。

有效吗?

修改:这是一个带有工作示例的jsFiddle:http://jsfiddle.net/Wc72f/

答案 2 :(得分:0)

试试这个:

ul.xoxo.blogroll li.img { 
    list-style-type: none;
    border: none;
    box-shadow: none;
}

如果我正确理解了这个问题,它会起作用