Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 要使Div标签中的图像填充浏览器屏幕,使其变大或变小吗_Css_Html - Fatal编程技术网

Css 要使Div标签中的图像填充浏览器屏幕,使其变大或变小吗

Css 要使Div标签中的图像填充浏览器屏幕,使其变大或变小吗,css,html,Css,Html,想要使Div标签中的图像填充浏览器屏幕的大小变大或变小,所以图像对于任何屏幕都是完美的尺寸 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body style="margin:0; height:100vh;"> <div al

想要使Div标签中的图像填充浏览器屏幕的大小变大或变小,所以图像对于任何屏幕都是完美的尺寸

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>
  <body style="margin:0; height:100vh;">
    <div align="center" style="vertical-align:top; border-top: 0px">
        <img src="images/Main.jpg" border="0">
    </div>
  </body>
</html>


检查此项。您可以对div标记中的图像使用宽度:100%和高度:100%,因为您希望图像在调整其大小(浏览器)时填充浏览器



此操作的目的是什么?背景?横幅?这会扭曲图像。
<img src="images/Main.jpg" border="0" style="max-width:100%; max-height:100%;">
<img src="http://thumbs.dreamstime.com/z/ice-cream-cone-29168018.jpg" border="0" style="width:100%;height:100%;">