Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a CSS selector for an IMG which has been constrained by max-width or max-height?

If I define the following CSS rule:

img {
    max-width:  200px;
    max-height: 200px;
    border: 1px solid black;
}

Is there a pure-CSS way of detecting those image objects that would have been larger without the size constraints? Something that semantically matches:

img:resized {
    border-color: green;
}

Alternatively: is there a way of only detecting large images in the first place? For example:

img {
    border: 1px solid black;
}
img[width>200px], img[height>200px] {
    max-width:  200px;
    max-height: 200px;
    border-color: green;
}

Thanks!

like image 593
Matty K Avatar asked Aug 22 '11 04:08

Matty K


1 Answers

No, there are no CSS selectors that can query style properties, whether declared or computed, as rendering of DOM elements has no relation to the DOM hierarchy.

like image 140
BoltClock Avatar answered Sep 23 '22 07:09

BoltClock