2015-09-20 54 views
1

我有一些非常基本的HTML和CSS,現在我已經知道我的代碼很好(至少對我來說),並且圖像加載到它們各自的字段中。但是一旦我刷新,它們就會消失。CSS圖像在刷新時消失

我正在使用Coda 2,它使用Safari瀏覽器進行預覽。我所有的代碼如下:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Input Images</title> 
    <link rel="stylesheet" type="text/css" href="css/input-image.css" /> 
</head> 
</head> 
<body> 
    <form> 
     <input type="text" id="email" /> 
     <input type="text" id="twitter" /> 
     <input type="text" id="web" /> 
    </form> 
</body> 
</html> 
input { 
    font-size: 120%; 
    color: #5a5854; 
    background-color: #f2f2f2; 
    border: 1px solid #bdbdbd; 
    border-radius: 5px; 
    padding: 5px 5px 5px 30px; 
    background-repeat: no-repeat; 
    background-position: 8px 9px; 
    display: block; 
    margin-bottom: 10px;} 

input:focus, input:hover { 
    background-color: #ffffff; 
    border: 1px solid #b1e1e4;} 
input#email { 
    background-image: url("images/email.png");} 
input#twitter { 
    background-image: url("images/twitter.png");} 
input#web { 
    background-image: url("images/web.png");} 
+0

它必須是ide的一些問題,嘗試使用絕對路徑爲您的網址:'「/images/email.png」'。 – gfpacheco

+0

這樣的痛苦,但它的工作。這只是一個IDE問題,因爲它看起來很奇怪。感謝指針,但。 – user3362856

+0

我發佈了它作爲答案,如果它有用,請接受它。 – gfpacheco

回答

0

它必須在IDE如何處理資產的路徑一些問題。

使用絕對路徑(這是正確的方式)應該工作:url("/images/email.png")

+0

這是相對路徑,不是嗎? – 0x860111

+0

不,路徑中的第一個斜槓意味着它是絕對路徑,並且與 – gfpacheco

+0

所需的位置無關。這是根路徑而不是絕對路徑。 –