Home >Web Front-end >CSS Tutorial >Can I Resize an Image Proportionally Using Only CSS?

Can I Resize an Image Proportionally Using Only CSS?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-30 01:56:29870browse

Can I Resize an Image Proportionally Using Only CSS?

Resizing an Image Proportionally with CSS

Query:

Can I resize an image to a percentage of its own size using only CSS?

Answer:

Yes, you can resize an image proportionally with CSS using the following methods:

Method 1: Visual Resizing

This method resizes the image visually, but not its actual dimensions in the DOM. The resized image will be centered within its original size.

img {
  transform: scale(0.5);
}

The above is the detailed content of Can I Resize an Image Proportionally Using Only CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn