Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

html - 使用CSS按比例调整图像大小? [重复](Resize image proportionally with CSS? [duplicate])

This question already has an answer here:

(这个问题在这里已有答案:)

Is there a way to resize (scale down) images proportionally using ONLY CSS?

(有没有办法使用ONLY CSS按比例调整大小(缩小)图像?)

I'm doing the JavaScript way, but just trying to see if this is possible with CSS.

(我正在做JavaScript方式,但只是想看看CSS是否可行。)

  ask by codingbear translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To resize the image proportionally using CSS:

(要使用CSS按比例调整图像大小:)

img.resize {
    width:540px; /* you can use % */
    height: auto;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...