0

所以我实际上只是从我网站的另一个目录、css 和所有目录中复制并粘贴了这段代码,但 BG 图像没有显示。它只是显示为白色。我确保在新目录中重新创建图像文件夹并重新上传背景,但背景只是不显示。这是我的 CSS(带有 bg 图像)

html,body {
    background: url(images/bg_body.png) ;
    font-family:Capriola;
        height:100%;
        margin:0;
        padding:0;
}

这是我的html:

<html>
<style>
html,body {
    background: url(images/bg_body.png) ;
    font-family:Capriola;
        height:100%;
        margin:0;
        padding:0;
}


</style>
<head>
<LINK REL=StyleSheet HREF="images/styles.css" TYPE="text/css" MEDIA=screen>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
        <title>SeaJay Source</title>


</head>
<body>
<body>
<center><br><br><br><br><br><br><br><br><br><br>
<img src="assets/logo.png" />
<div id="posting" class="posting">
<div class="title" id="title" color="white">Login</div>
<div id="texts" class="texts">
Welcome to SeaJay Source!<br>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>" >
Username: <input class="input" type="text" name="username" placeholder="Username" /><br>
Password: <input class="input" type="password" name="password" placeholder="Password" /><br>
<input class="button" type="submit" value="Login" /> <br>
</form>

</div>
</center>
</body>
</html>

如您所见,我也尝试在 html 文件中包含样式,但这不起作用。

4

1 回答 1

2

从另一个目录

那是你的问题,几乎可以肯定。

始终指定相对于您的域的根的 URL。它应该看起来像url('/path/to/image.png')

CSS 中的 URL 可能会造成混淆,因为有些东西使用 HTML 文件的位置作为基础,而另一些则使用 CSS 文件的位置。指定相对于固定基础的 URL 更容易:根。

于 2012-09-09T22:36:54.167 回答