senzacionale
senzacionale

Reputation: 20916

set list-style-type: none only on image when using ul li

This is my CSS

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

now i use list-style-type: none; and cicrcle is not visible. But i would like that circle will be visible when i am using ul li and not visible when ul li has img tag.

Is that possible. If i set

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

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

circles are everywhere.

Upvotes: 1

Views: 644

Answers (3)

Munchies
Munchies

Reputation: 444

If i got you right, if there is a <img> inner a <ul>, you want the list-type-style to be none, and otherwise a circle?

if so, i think you need to use jQuery:

jQuery:

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

The script loops trough every <img> tag, and with .parent().css() it manipulates the css attributes of its parent, what the <li> would be.

Did it work?

Edit: Here's a jsFiddle with a working example: http://jsfiddle.net/Wc72f/

Upvotes: 1

frx
frx

Reputation: 76

try this:

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

it works if I understand the question correctly

Upvotes: 0

Olaf Dietsche
Olaf Dietsche

Reputation: 74078

AFAIK, there's no CSS selector for a parent of a specific child. If you want to stay with CSS only, you can add another class, e.g. imglist or similar, and select on that.

Upvotes: 1

Related Questions