微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 如何自动调整移动网站的图片大小?

我尝试了Google搜索,但仍然无法弄清楚如何根据各种移动设备的宽度来调整图像的大小.这是我的尝试:

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>

解决方法

你的css没有任何效果,因为外部元素没有定义宽度(并且身体也缺少).

不同的方法是提供已经缩放的图像. http://www.sencha.com/products/io/例如根据观看设备递送已经缩小的图像.

原文地址:https://www.jb51.cc/html/224231.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐