2015-09-20 55 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

所需的位置无关。这是根路径而不是绝对路径。 –