gpt4 book ai didi

html - 热门将图像作为背景放在CSS中

转载 作者:太空宇宙 更新时间:2023-11-03 23:32:43 25 4
gpt4 key购买 nike

我正在尝试添加图像作为背景。我相信下面的代码是正确的,但它不起作用。请任何人帮助我。我的图片在 images 文件夹中,该文件夹与 index.html 位于同一目录中。

body{
background-image:('images/background.jpg');
background-repeat: repeat;
background-attachment:fixed;
}

在之前的元素中,我有以下内容:此代码有效,但上面的代码无效。我不明白为什么

body{
background-color:white;
color:#404040;
font-size:11pt;
font-family:Georgia, Garamond, serif;
background-image:url("images/silverware.jpg");
background-repeat:repeat;
background-attachment:fixed;
}

最佳答案

它不起作用,因为您在背景图像属性中遗漏了 url 前缀:

body{
background-image:('images/background.jpg');
background-repeat: repeat;
background-attachment:fixed;
}

应该是:

body{
background-image:url('images/background.jpg');
background-repeat: repeat;
background-attachment:fixed;
}

关于html - 热门将图像作为背景放在CSS中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24843938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com