Home > Web Front-end > HTML Tutorial > I am using CSS to compile a table and want to add a background image to the table header, but the background of the form is blank. The specific code and related information are as follows. Waiting online! _html/css_WEB-ITnose

I am using CSS to compile a table and want to add a background image to the table header, but the background of the form is blank. The specific code and related information are as follows. Waiting online! _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:13:26
Original
1865 people have browsed it




 
  
 
    .nav
    {
        background-image:url("images/home.jpg") no-repeat;
    }
    
    
      1111
      1111
      1111
      1111
    
    
这个NAV的例子我是在网上找到的,用了之后完全没效果,请各位大神帮忙!


回复讨论(解决方案)


  .nav
  {
  background-image:url("images/home.jpg") no-repeat;
  }
  

放到表格外面去,

然后改成
.nav
{
background:url("images/home.jpg") no-repeat;
}

background-image是不能写 no-repeat的background才可以

老大 我放到表格外边了 可还是没效果 是不是我放错位置了?  你告诉一下我具体放到哪儿吧 谢谢了
  .nav
  {
  background-image:url("images/home.jpg") no-repeat;
  }
  

放到表格外面去,

然后改成
.nav
{
background:url("images/home.jpg") no-repeat;
}

background-image是不能写 no……

例子

<style type="text/css">body,table{  font-size:12px;} table{  table-layout:fixed;  empty-cells:show;   border-collapse: collapse;  margin:0 auto;}td{  height:20px;}h1,h2,h3{  font-size:12px;  margin:0;  padding:0;}.title { background: #FFF; border: 1px solid #9DB3C5; padding: 1px; width:90%;margin:20px auto; }  .title h1 { line-height: 31px; text-align:center; background: #2F589C url(th_bg2.gif); background-repeat: repeat-x; background-position: 0 0; color: #FFF; }  .title th, .title td { border: 1px solid #CAD9EA; padding: 5px; }   table.t1{  font-family: sans-serif;  border:1px solid #cad9ea;  color:#696969;}table.t1 th {  height:30px;}table.t1 td,table.t1 th{  border:1px solid #cad9ea;  padding:0 1em 0;}table.t1 tr.a1{  background-color:#DCDCDC;}  .nav  {  background:url("http://www.fjms.net/pic/vImage/2008-08/20080806122054907875.jpg") no-repeat;  }</style>   <table width="80%" id="mytab" border="0" class="t1">  <tr class="nav">  <td class="nav">1111</td>  <th>1111</th>  <th>1111</th>  <th>1111</th>  </tr>  </table>
Copy after login

I solved it, but nav still doesn’t work. I added the background image to the table and it worked. . . Example

HTML code