为自适应图像使用 CSS 宽度属性
为自适应图像设置 100% 的宽度属性。你可以尝试运行以下代码以让图像自适应
示例
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content="width=device-width, initial-scale = 1.0">
<style>
img {
width: 100%;
height: auto;
}
</style>
</head>
<body>
<p>To check the effect, you need to resize the browser.</p>
<img src = "https://tutorialspoint.com/python/images/python-data-science.jpg"
alt = "Python Data Science" width = "400" height = "300">
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP