Give style attributes to sub-elements inside a <style> tag?
My <style>
for thumbnails currently looks like this:
<style type="text/css">
img.TN {
width: 100%;
margin-bottom: 5.294%;
cursor: pointer; }
</sty开发者_如何学Gole>
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!
You can do use a .class img
selector, like this:
.classTheDivHas img {
width: 100%;
margin-bottom: 5.294%;
cursor: pointer;
}
You would have to name your style like this
#containerDiv img { ... }
and set the id of the outer div to containerDiv
<div id="containerDiv">
<img...>
<img...>
<img...>
<img...>
</div>
精彩评论