CSS初学者,背景图片不会显示 [英] CSS beginner, background image won't show up

查看:60
本文介绍了CSS初学者,背景图片不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的背景图片不会显示.是否需要在HTML中标记图像?也许是职位参考或其他?请帮忙!

My background-image won't show up. Do I need to tag the image in the HTML? Maybe position reference or something? Please help!

<html>
<head>
    <link type="text/css" rel="stylesheet" href="sespe.css"/>
    <title>Sespe Pizza Co.</title>
</head>
<body>
    <div id="header1">
        <h1>Sespe Pizza Co.</h1>
    </div>
    <div id="mb1"></div>
    <div id="mb2"></div>
    <div id="mb3"></div>
    <div id="mainPage">

    <div id="b1"></div>
    <div id="b2"></div>
    <div id="b3"></div>
    <div id="b4"></div>
    <div id="b5"></div>
</body>
</html>

CSS .....

CSS.....

body {
    background-image:         url('/Users/Username/Downloads/3634195609_f6b7edac1b_b.jpg'); 
}

推荐答案

您的路径是问题所在.您正在导航到下载文件夹.将您的图像放在站点文件夹中的文件夹中,称其为"images",然后像这样将其称为您的CSS.如果新的"images"文件夹与css文件夹处于同一级别,则第一个选项将起作用. ../,因为您要转到一个文件夹以转到 images .

Your path is the problem. You are navigating to your downloads folder. Place your image in a folder in your site folder, call it say 'images' and then call it into your css like this. If your new 'images' folder is on the same level as your css folder, the first option would work. ../because you are going up one folder to get to images.

body {
  background-image: url('../images/3634195609_f6b7edac1b_b.jpg');
}

在您的情况下,您的css文件似乎不在css文件夹中,因此您可以直接进入images文件夹而无需进入另一个级别:

Seems in your case, your css file is not in a css folder, so you can just get to your images folder without going to a different level:

body {
  background-image: url('images/3634195609_f6b7edac1b_b.jpg');
}

这篇关于CSS初学者,背景图片不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆