user1269988
user1269988

Reputation: 105

How do you control placement of different images inside the same DIV with CSS?

I know this should be simple but I can't seem to make it work. I have six boxes with info with icon images that I made into a list. I use div# li img to control the placement of the icons. But on the last box there is an Icon img and then four small social media icon images. I can't figure out how to control the social media icon img placement (the padding) since the div# li img overrides it.

Upvotes: 0

Views: 68

Answers (3)

Bharadwaj
Bharadwaj

Reputation: 2553

You can still add style attribute to li and can controle the padding for images

Upvotes: 0

icktoofay
icktoofay

Reputation: 129011

If you want to target truly ancient browsers that don't support > as well, you can use a more specific selector to override it:

#grid li a img {
    padding: 0;
}

Upvotes: 0

Explosion Pills
Explosion Pills

Reputation: 191749

Use #grid li > img in order to select only images that are children of the li. The social media icons are younger descendants.

Upvotes: 1

Related Questions