Home  >  Article  >  Web Front-end  >  How to make images smaller with css

How to make images smaller with css

WBOY
WBOYOriginal
2021-11-25 16:17:0121256browse

Method: 1. Use the width and height attributes to shrink the image, the syntax is "picture object {width: width; height: height;}"; 2. Use the "background-size" attribute to shrink the image, the syntax is " Picture object {background-size: width height;}".

How to make images smaller with css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to make images smaller in css

#1. In css, we can set the height and width of the image through the width and height attributes. Image size to achieve the purpose of reducing the image.

Let’s take a look at the example below. The example is as follows:



    
        
        
    

原始图片大小

How to make images smaller with css

通过CSS使图片缩小

How to make images smaller with css

Output result:

How to make images smaller with css

2. In css You can use the background-size attribute to achieve image reduction. Let's take a look at the example below:



    
        
        
    

原始图片大小


通过CSS缩小背景图片

Output result:

How to make images smaller with css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to make images smaller with 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