Home > Article > Web Front-end > Implementation methods and codes for controlling image size display using css_Experience exchange
Sometimes images are too large and disrupt the neat layout of the web page. At this time, you can use css to force the height or width of the image to be compressed proportionally
The css code is as follows:
img,a img{
border:0;
margin:0;
padding:0 ;
max-width:590px;
width:expression(this.width>590?"590px":this.width);
max-height:590px;
height:expression(this. height>590?"590px":this.height);
}
In this way, if the height or width of the image exceeds 590px, it will be proportionally compressed to 590px. If it does not exceed, it will be displayed at the original size.