html - 为什么我的 CSS 文件中的背景图片没有应用于我的网页?

标签 html css background-image

index.html

<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="style sheets/style1.css" type="text/css"/>
        <title>Colorado National Parks and Monuments</title>
    </head>

<body>
    <h1>Colorado National Parks and Monuments</h1>
    <br/>
    <h2><img src="images/Colorado Parks.gif" alt="Button to Colorado Parks webpage"/></h2>
    <h2><img src="images/Colorado Monuments.gif" alt="Button to Colorado Monuments webpage" usemap="#goToColMons"/></h2>
    <h2><img src="images/Spotlight Park.gif" alt="Button to Spotlight Park webpage"/></h2>
    <h2><img src="images/Places to Stay.gif" alt="Button to places to Stay webpage"/></h2>

    <map name="goToColMons">
        <area shape="rect" coords="0,0,139,40" href="colorado_monuments.html"/>
    </map>

    <p>Colorado offers unequaled natural mountain scenery, abundant wildlife,</p>
    <p>and more outdoor activities than you can imagine. The name Colorado</p>
    <p>comes from the Spanish word “colorado” which means “reddish</p>
    <p>color.” On August 1, 1876, President Ulysses Grant proclaimed</p>
    <p>Colorado the 38th state.</p>

</body>

</html>

style1.css

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

h1{
text-align: center;
font-family: sans-serif;
color: brown;
}

index.html 的位置与文件夹图像和样式表位于同一文件夹中。

图片backg.jpg的位置在images文件夹中。

style1.css 的位置在样式表文件夹中。

最佳答案

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

我觉得路错了,你必须往上走。

关于html - 为什么我的 CSS 文件中的背景图片没有应用于我的网页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29220907/

相关文章:

html - 防止文本输入在 IE 中扩展

jquery - Jquery Div单击音频播放器?

css - 在 100% 宽度背景内居中并为内容提供固定宽度的最佳方法是什么?

html - 模糊背景图像缩小它,如何在不缩小的情况下模糊?

javascript - 为什么 innerHTML 返回 null

javascript - 单击另一个 <select> 时更改选中的单选按钮

html - 使用 CSS 居中图像(水平和垂直)

html - 如何将 block 内的图像和文本居中

css - 正文中未显示内容背景图片

html - 如何使用 CSS 加载基于浏览器支持的图像格式?