2016-05-14 76 views
0

我的网页底部显示图像时出现问题。显示图像CSS

这就是我想要的东西:

Wanted

但它无法加载图像。

这是我的代码:

的index.html

<!DOCTYPE html> 

<html> 
    <head> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> 
     <link rel="stylesheet" type="text/css" href="css/style.scss"> 
     <title>Hello World</title> 
    </head> 
    <body> 
     <header class="header"> 
      Mon App de Météo 
     </header> 
     <section class="view"> 

     </section> 
     <nav class="nav"> 
      <a href="#home"><i class="home"></i></a> 
      <a href="#about"><i class="about"></i></a> 
     </nav> 
    </body> 
</html> 

的style.css

.header{ 
    position: absolute; 
    top: 0; 
    left: 0; 
    right: 0; 
    height: 60px; 
    line-height: 60px; 
    color: #FFF; 
    text-transform: uppercase; 
    text-align: center; 
    background-color: #11a7ab; 
} 

.nav{ 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    height: 60px; 
    line-height: 60px; 
    text-align: center; 
    background-color: #4f597b; 
} 

.home{ 
    background-image: url('../img/icon/home.png'); 
    background-repeat: no-repeat; 
} 

.about{ 
    background-image: url('../img/icon/about.png'); 
    background-repeat: no-repeat; 
} 

a{ 
    display: block; 
    width: 50%; 
    float: left; 
} 

这是层级:

hierarchy

控制台不显示任何错误,这让我想知道我做错了什么?

谢谢!

回答

2

如果这就是你所有的CSS,问题是空的<i>元素没有大小,所以背景图像有一个0x0的空间来处理。解决方案:显式给i元素显示图标的大小。

+0

工作正常!我还必须添加一个'display:inline-block;' – user1885868

+2

OK。如果这样做,你能点击左边的复选标记将其标记为解决方案吗?这样,这个问题就不会再出现在未解决的问题列表中。 –