HTML显示适合屏幕的图片

HTML显示适合屏幕的图片,html,Html,我有下面的代码,显示一张图片: <html> <head> <style>* {margin:0;padding:0;}</style> </head> <body style="margin: 0; padding: 0"> <center> <script type='text/javascript'><!--//<![CDATA[ var m3_u = (location.pr

我有下面的代码,显示一张图片:

<html>
<head>
<style>* {margin:0;padding:0;}</style>
</head>
<body style="margin: 0; padding: 0">
<center>
<script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'URL1':'URL2');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=1");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]>--></script><noscript><a href='URL3' target='_blank'><img src='URL4' border='0' alt=''/></a></noscript>
</center>
</body>
</html>

*{边距:0;填充:0;}
我想让图片适合屏幕,我试着把width=“100%”放在img中,在a href中。。。但它的尺寸总是一样的


我该怎么做呢?

您可以使用
backstretch
jquery
Backstretch
是一个jQuery插件,允许您向任何页面添加动态调整大小的背景图像。图像将拉伸以适应页面,并随着窗口大小的变化自动调整大小

以下是一个例子:


你能做的就是把图像作为背景放在一个元素上,让元素覆盖整个屏幕。(你不需要任何JS,只需要HTML和CSS。)
例如:

HTML

(另外,请注意,如果不需要链接功能,可以将
元素替换为

根据文档,您可以尝试通过添加背景盖来适应屏幕上的图像


我猜你不明白javascript是做什么的?我知道这段代码显示了一幅图,我不在乎它是如何工作的,我只想把它放大。
<a id="imgA" href='http://www.stackoverflow.com' target='_blank' /a>
#imgA {
    background-image: url(<url_to_img>);

    /* Make the image cover the whole element area */
    background-size: 100%;

    /* Make the element occupy the whole window */
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
}
#img
{
background:url(img.jpg);
background-size:cover;
}