我嘗試了谷歌搜索這個,仍然無法弄清楚如何調整圖像的寬度爲各種移動設備。這裏是我的嘗試:如何自動調整移動網站的圖片大小?
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