我尝试了谷歌搜索这个,仍然无法弄清楚如何调整图像的宽度为各种移动设备。这里是我的尝试:如何自动调整移动网站的图片大小?
CSS:
img.test {
width: 100%;
height: auto;
}
HTML:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport">
<link rel="stylesheet" href="../includes/style.css">
</head>
<img class="test" src="../includes/foo.jpg">
但图像仍然被加载到它原来的缩放。我是一个CSS和HTML新手,所以任何帮助将是伟大的!
编辑:
感谢您的回复。这是一个现在有效的修订版本。
HTML:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport">
<link rel="stylesheet" href="../includes/style.css">
</head>
<body width = "device-width">
<img class="test" src="../includes/buoy_map.jpg">
</body>
你给出了图像的父元素的任何一个宽度? – Gerben
你的'img'标签应该放在'body'里面。您实际上并不拥有身体标记,因此添加一个:-) – Bojangles