使用 CSS max-width 属性以实现响应式图像
你可以尝试运行以下代码来为响应式图像实现 max-width 属性
示例
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0">
<style>
img {
max-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