In CSS, you can use the margin-left attribute to set the distance from the left side of the image. The function of this attribute is to set the left margin of the element. You only need to add "img{margin-left: distance value" to the image element. ;}" style is enough.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In CSS, you can set the distance from the left side of the image through the margin-left attribute.
The margin-left attribute sets the left margin of the element. Negative values are allowed.
Example:
<!DOCTYPE html> <html> <head> <style> img{ border: 1px solid red; } #img2{ margin-left: 20px; } </style> </head> <body> <img src="img/1.jpg" style="max-width:90%" / alt="How to set the distance of the image from the left in css" > <img src="img/1.jpg" style="max-width:90%" id="img2" / alt="How to set the distance of the image from the left in css" > </body> </html>
Rendering:
Description:
margin-left attribute value Units can use px, %, em, rem, etc.
(Learning video sharing: css video tutorial)
The above is the detailed content of How to set the distance of the image from the left in css. For more information, please follow other related articles on the PHP Chinese website!