2011-12-20 68 views
0

我有一个的div和div有一个img标签,但图像没有在DIVDIV和CSS问题

这里显示是我的代码

<div id="infscr-loading" > 
<img src="http://jquerystyle.com/-/img/ajaxLoader.gif" alt="Loading..."> 
<div> 
<em>Loading the next set of posts...</em> 
</div> 
</div> 

<style type="text/css"> 
#infscr-loading { 
background: -moz-linear-gradient(center top , #747D84 0%, #434F56 100%) repeat scroll 0 0 transparent; 
border-top-left-radius: 5px; 
border-top-right-radius: 5px; 
bottom: 0; 
font-size: 0.8em; 
font-style: normal; 
font-weight: normal; 
height: 50px; 
left: 50%; 
margin-left: -45px; 
padding-top: 20px; 
position: fixed; 
text-align: center; 
text-indent: -999em; 
width: 90px; 
background-repeat:no-repeat; 
background-position: center center; 
} 
</style> 

,这里是我的div和样式表。为什么图像不在div内显示。任何人都可以指出.....感谢

回答

5

尝试从你的CSS删除text-indent: -999em;

负文本缩进隐藏所有文字/图片和其他内嵌的内容-999em从视图。

+0

...天才!大声笑。 – 2011-12-20 12:50:39

-2
  1. 检查网址http://jquerystyle.com/-/img/ajaxLoader.gif
  2. 接近<img src="http://jquerystyle.com/-/img/ajaxLoader.gif" alt="Loading..."/>

更新前应该有斜线:

我发现,因为text-indent: -999em;。如果您删除它,图像将会出现。

+0

你可能已经检查自己,看看它的工作原理。并且,不需要在IMG标签中不需要斜线,也不需要指定文档类型,因此根据HTML5规范,在HTML 5中不需要结束斜线。所以,在两种情况下都是错的,-1。 – 2011-12-20 12:50:00

+0

@Truth对不起,我想在检查他的html时发表一些评论 – hungneox 2011-12-20 12:51:14

+0

@真正的每个人都在堆栈溢出是如此之快:)) – hungneox 2011-12-20 12:57:25

1

根据您的文档类型,尝试正确关闭图像标签。

<img src="http://jquerystyle.com/-/img/ajaxLoader.gif" alt="Loading..." /> 

此外,虽然这可能与您的问题没有任何关系,但您可以显着清理自己的风格。您不需要背景位置并重复,那些可以直接合并到您的速记属性中。这两个边界半径属性也可以合并为一个简写。

+1

我想知道为什么这会得到提升。这绝不是解决问题的办法。 – 2011-12-20 12:52:31

+0

它实际上得到了两次投票。 – 2011-12-20 15:39:31

4

您的text-indent: -999em;正在将所有文字(包括图像)移出屏幕。

3

margin-left: -45px;text-indent: -999em;肯定会导致这个问题

+1

'margin-left:-45px;'with'left:50%;'在屏幕中央放置一个宽度为90px的元素。 – 2011-12-20 12:48:25

+0

@TomvanderWoerdt你是对的,我没有注意到这一点。 – AndroidHustle 2011-12-20 12:49:59