簡體   English   中英

CSS背景不起作用

[英]CSS Background doesn't work

我有個問題。 我嘗試向表格單元格添加背景,但是不起作用。

.price-table td.left-up {
    background: url("img/left-up.png") no-repeat;
    width: 181px;
    height: 118px;
}

和HTML:

<div class="price-table">
  <table>
    <tr>
      <td class="left-up">
        sdst
      </td>
    </tr>
  </table>
</div>

您在此處指定了相對路徑名-這可能就是為什么圖像未加載的原因。 請記住,相對路徑相對於CSS文件而不是頁面有效。 例如:

/site
  -page.htm
  /css
    -site.css
  /img
    -left-up.png

如果這是您的文件夾結構,則需要:

background: url("../img/left-up.png") no-repeat;

這是因為圖像相對於css文件是上一級的。 希望能幫助您找出正確的路徑!

使用純鏈接到您的圖片,例如。 http://yoursite.com/img/left-up.png

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM