freeCodeCamp/guide/chinese/html/attributes/img-width-attribute/index.md

28 lines
689 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Img Width Attribute
localeTitle: Img宽度属性
---
## Img宽度属性
HTML“width”属性指的是图像的宽度。引号中的值是像素数量。
例如,如果您已经通过`src`属性设置了图像链接则可以添加width属性如下所示
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Img Width Attribute</title>
</head>
<body>
<img src="image.png" alt="Image" width="100"/>
</body>
</html>
```
在上面的代码段中有一个图像标记图像的宽度设置为100像素。 `width="100"`
#### 更多信息:
[关于img标签的MDN文章](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)