Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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-仅显示图像背景的左上部分_Css - Fatal编程技术网

CSS-仅显示图像背景的左上部分

CSS-仅显示图像背景的左上部分,css,Css,我试图将图像作为背景,但使用此选项时: …仅显示零件。您可以使用: background-size: cover; 您可以找到有关背景大小属性的文档:尝试以下背景属性 body { background-image: url('./image.jpg'); background-position: center; background-repeat: no-repeat; background-size: cover; } 使用“背景大小”样式可以修改背景图像在父对象中的大小和位置

我试图将图像作为背景,但使用此选项时:

…仅显示零件。

您可以使用:

  background-size: cover; 

您可以找到有关背景大小属性的文档:

尝试以下背景属性

body {
background-image: url('./image.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
使用“背景大小”样式可以修改背景图像在父对象中的大小和位置

身体{ 背景:url'https://i.stack.imgur.com/n3OMH.jpg"不重复,; 背景尺寸:封面; } 试试这个:

 background-size: 100% 100%; /*first value is for width and next for height. If you use only first of them, it will be used as width, and height will be auto*/

background-size: cover;