CSS background-image url只接受完整路径

时间:2017-03-30 13:12:07

标签: html css

我想使用这样的相对路径:

background-image:url("images/cover.png");

然而,当我从它切换它时:

background-image:url("D:/WebDesign/website/images/cover.png");

图像停止工作。我也尝试过使用

url(images/cover.png);

url("/images/cover.png");

url(/images/cover.png);

但是除了完整路径之外,它们似乎都不起作用,索引文件位于网站文件夹中。

2 个答案:

答案 0 :(得分:2)

  

后台网址需要与您的css文件相关,而不是您的HTML文件。

因此,如果您的css文件位于D:/WebDesign/website/css/yourfile.css,则首先需要使用../

返回您的网站文件夹

然后您的相对网址就会显示为

background-image:url("../images/cover.png");

答案 1 :(得分:1)

试试这个:

Private Sub Loop_Array()

Dim marrLoop() As Variant 'this is an array which which will be looped through instead of the range to "activate" all its functions
Dim mintRow As Integer 'this is the row index of the array
Dim mintCol As Integer 'this is the column index of the array

marrLoop = Range("polynomial")
For mintRow = 1 To UBound(marrLoop, 1) ' First array dimension is rows.
    For mintCol = 2 To UBound(marrLoop, 2) ' Second array dimension is columns.

            marrLoop(mintRow, mintCol) = Replace(marrLoop(mintRow, mintCol), "X", "x")
            marrLoop(mintRow, mintCol) = Replace(marrLoop(mintRow, mintCol), ",", ".")
            marrLoop(mintRow, mintCol) = Replace(marrLoop(mintRow, mintCol), "x", marrLoop(mintRow, 1))
            marrLoop(mintRow, mintCol) = "=" & marrLoop(mintRow, mintCol)

    Next mintCol
Next mintRow
Range("polynomial") = marrLoop

End Sub

..意味着登上1个目录。