Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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(100%宽度100%高度)_Css_Image_Background - Fatal编程技术网

Css 带背景图像的Div(100%宽度100%高度)

Css 带背景图像的Div(100%宽度100%高度),css,image,background,Css,Image,Background,我想要实现的是一个具有反映div大小的背景图像的div,我不在乎谁保持纵横比 一些测试 ; ; ; 试试这个: background-size: 100% 100%; 或 这是一个糟糕的问题,你可以使用谷歌。这是最基本的东西,复制品 <div style='position:absolute;width:"+obj.width+"px;height:"+obj.height+"px;margin-left:"+obj.left+"px;margin-top:"+obj.top+

我想要实现的是一个具有反映div大小的背景图像的div,我不在乎谁保持纵横比

一些测试

试试这个:

background-size: 100% 100%;


这是一个糟糕的问题,你可以使用谷歌。这是最基本的东西,复制品
<div style='position:absolute;width:"+obj.width+"px;height:"+obj.height+"px;margin-left:"+obj.left+"px;margin-top:"+obj.top+"px;background-image:url(img.png);background-size: cover;background-repeat: no-repeat;border:1px solid red;'>;
<div style='position:absolute;width:"+obj.width+"px;height:"+obj.height+"px;margin-left:"+obj.left+"px;margin-top:"+obj.top+"px;background-image:url(img.png);background-repeat: no-repeat;border:1px solid red;'>;
background-size: 100% 100%;
background-size:auto 100%;