views:

101

answers:

2

My <style> for thumbnails currently looks like this:

<style type="text/css">
    img.TN {
        width: 100%;
        margin-bottom: 5.294%;
        cursor: pointer; }
</style>

This is annoying, because I have to apply this style to every single thumbnail image individually, when there could be any number of them on the screen at any given time. All of the thumbnails are inside a single <div> that groups them together, and I'd like to apply a single style to the <div> that will push the attributes I need down to all of the the <img> elements nested inside, regardless how many thumbnails there are.

I'm using ASP.NET 2.0, and CSS 2.0

Does anyone know how to do this? Thanks!

+5  A: 

You can do use a .class img selector, like this:

.classTheDivHas img {
    width: 100%;
    margin-bottom: 5.294%;
    cursor: pointer; 
}
Nick Craver
Works perfectly!
Giffyguy
+2  A: 
Claudio Redi
+1 for good solution.
Giffyguy
'#' is a prefix for ids. If you use an css class the prefix is '.' for a tag there is no prefix. You should use ids on css styles everytime you can. Better performance for rendering the tags
Claudio Redi
@Claudio - While that's always true for javascript, it's not always true for CSS, that depends on the browser.
Nick Craver
I see. Thanks, guys.
Giffyguy
@Nick: thanks for the feedback. I also feel that since some time ago we started using the class and id attributes indistinctly to identity tags. While not a big deal It's not supposed to be like that :-)
Claudio Redi