开发者

How can I make an image size depend on its position?

How would i make an image nested in a div to set its size depending on the div class. making an image 开发者_开发问答smaller depending where it is in the page. For example:

<div class="a">
    <img src="a.jpg">
<div>
<div class="b">
    <img src="a.jpg">
<div>

I would like to set the image nested in "a" to size 10X10 and the other to size 20X20, how would i do this without creating different classes for the images?


in yout css file add this:

.a img {width: 10px; height: 10px}
.b img {width: 20px; height: 20px}

this will make any image in "a" be of size 10X10 and any image in class "b" be of size 20X20.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜