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;