In the past, JavaScript was used to control the image size. Sometimes our advertisements become small, so they are generally directly controlled in the content area, this method uses the css expression method. I wonder if the Taoist school has ever encountered such a situation: When the CSS controls the image size, if the width of the image is written to death, for example, img {width: 500px ;}, of course, if the image width is greater than PX, it can be well controlled not to make it too large, but if the image width is less than PX, for example, if it is only PX, the writing method just now will increase the image by 5 times, obviously, this is not what we want to see.
So how can CSS differentiate the size of these images? Easy to use. See:
The Code is as follows:
Img {width: expression (this. width> 500? "500px": this. width + "px ");}
You can use this code in CSS to control large images and small images respectively. It means that if the image width is greater than PX, the image will be displayed in PX size. If the image width is smaller than PX, the image will be displayed in the original size! How is it? Is it really easy?
Disadvantages: Increase the client load, which is usually implemented in js.