如何缩放背景图片

Sm00rf9000

我有一个我正在工作的网站,我想要一个背景,中间是白色,网站上还有其他颜色,例如黑色。我做了这样的代码。

body { background-color: #000000; background-image: url('BackgroundImg.png'); }

现在我的问题是,背景图像会拉紧,以适合整个屏幕,我只希望它位于中间且具有特定的宽度大小。如何缩放背景图像?

胡拉姆·谢里夫(Khurram Sharif)

以下代码为您提供居中的图像,而无需重复,您可以通过指定位置来调整位置

 body {
background-color: #000000;
background-image: url('BackgroundImg.png');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center; }

调整尺寸:手动用图像尺寸替换尺寸x,尺寸y

 body {
background-color: #000000;
background-image: url('BackgroundImg.png')size-x,size-y;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center; }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章