html - 为什么我的背景 CSS 图像不显示

标签 html css

所以我制作了一个背景图像,它只是两个彩色条以匹配我的标题和导航栏。我只是想让它水平重复,但它没有出现。这是显示我的文件和图像的屏幕截图: enter image description here

感谢您的帮助!

HTML

   <!doctype html>
<html lang="en">
<head>
   <meta charset="utf-8" />
   <title>Tech MAX'd</title>
   <link rel="stylesheet" href="css/main.css" type="text/css"/>
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
   <script src="js/general.js" type="text/javascript"></script>
</head>


<body>  
   <div id="big_wrapper">
      <header id="top_header">
         <h1>Welcome to Tech MAX'd</h1>
      </header>

      <nav id="top_nav">
         <ul>
            <li>...

CSS

*{
   margin:0px;
   padding:0px;
}
h1{
    padding: 2px;
    color: #ffffff;
    font: 24px Palatino;
    display: inline-block;
}
h2{
   font: bold 14px Palatino;
}
header, section, footer, aside, nav, article, hgroup{
   display:block;
}
body{
margin: 0px;
padding: 0px;
text-align: center;
background: #e0e0e0 url(images/tmbackground.gif) repeat-x;
}
#big_wrapper{
   min-width:1000px;
   max-width: 1000px;
   margin: auto;
   text-align:left;
}
#top_header{
   padding:20px;
   background-color: #820000;
}
#top_nav{
   padding:7px 7px 7px 20px; /* top,right,bottom,left */
   background: -webkit-gradient(linear, left top, left bottom, from(#e9e9e9), to(#b6b6b6))
}
#top_nav li{
   display:inline-block;
   list-style:none;
   padding-right:25px; /*space between links*/
   font: bold 14px Tahoma;
}
a.topLinks{
    color: #4e4e4e;
    font: bold 16px Century;
    text-decoration: none
}
a.topLinks:hover{
    color: #820000;
    font: bold 16px Century;
    text-decoration: none
}
#new_div{
   display:inline;
}
#main_section{
   min-width: 630px;
   max-width: 630px;
   border: 1px solid #820000;
   background-color: white;
   float: left;
   margin: 20px;
   padding: 20px;
}
#side_news_banner{
    float: left;
    margin-top: 20px;
    margin-left: 15px;
}
.side_news{
   border: 1px solid red;
   width:220px;
   margin: 20px 0px;
   padding: 30px;
   background: #66CCCC;
}
#the_footer{
    clear: both;
   text-align:center;
   padding: 20px;
   border-top: 2px solid green;
}
article {
   background: #FFFBCC;
   border: 1px solid ;
   padding: 20px;
   margin-bottom: 10px;
}
article footer{
   text-align:right;
}

最佳答案

除非目录images是css的子目录,否则需要使用

url(../images/background.gif)

因为位置是相对于css文件的。

此外,通常在选择器和“{”之间留一个空格,即 body { 而不是 body{

关于html - 为什么我的背景 CSS 图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10065502/

相关文章:

html - 在 css/html 中创建菜单栏

CSS(3?) : Create background with rectangle center bright

html - 清除绝对定位的侧边栏?

jquery - 仅滚动子元素

javascript - jQuery/HTML - 在使用等宽字体时,如何使空格 ( ) 占用与另一个字符相同的空间量?

css - CSS选择器,如:after,:before,不会显示出来

javascript - Spring 中页面为 .html 时的 session 处理

html - 在django模板中将字符串转换为html代码

jquery - 一段时间后在两个 jQuery 函数之间切换

php - 如果循环不返回任何帖子,如何隐藏带有文本的 div?