2012-01-29 75 views
0

我在这里做错了什么?我无法让精灵正常工作。当我检查元素时,它不是正确的高度或宽度。我已经得到了精灵的工作有一个背景图像的容器div,但我不认为在这种情况下有一个包装是正确的。css和精灵 - 意外的结果

这里是我想要做的..

<html> 
<style> 
.bottomtable{display:block;} 
.bottomtable .close {float: right;margin-right:5px;margin-top:25px;display:inline;position:relative;background-image:url('http://www.freeimagehosting.net/o2gz4');background-position:-278px -18px;height:7px;width:7px;} 
.bottomtable .close a {height:7px;width:7px;} 
.bottomtable .titletext{text-align: right;float: right;margin-right:5px;margin-top:-20px;display:block;} 
.bottomtable h5{margin:0;padding:0;font-size: 14px;font-weight:normal;display: inline;} 
.bottomtable ul {display:block;padding:5px;margin:0;} 
.bottomtable li {list-style-type:none;padding:10px;margin:0;height:75px;display:block;} 
.bottomtable li a{text-decoration:underline;font-weight:bold;display:block;margin-bottom:5px;} 
.bottomtable li a span{display:block;text-decoration:underline;font-weight:bold;margin:2px 0 4px;} 
.bottomtable ul img {display:inline;float:left;margin-top:-2px;margin-right:20px;} 
</style> 
<body> 
<div class="bottomtable"> 
<ul> 
    <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div>      </li> 
    <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div> </li> 
    <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div> </li> 
    <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div> </li> 

</ul> 
</div> 
</style> 
</html> 

`

所有你能看到的是X的一小部分

如果我不把那链接之间的空白空间,它根本不显示任何内容...必须有一些我只是做错了。它是什么?我检查了网站的tuns,他们似乎并不需要那里的空间。

+0

哪个背景精灵从http:// WWW。 freeimagehosting.net/o2gz4你想展示? – Sabari 2012-01-29 09:12:49

+0

这里发生了什么,为什么你有明确的权利的divs?我认为你需要回过头去学习一些关于CSS及其工作方式的知识。 如果你能告诉我们你想要的结果,我们可以帮你重写那个CSS :) – Kyle 2012-01-29 09:15:22

+0

我正在试图做小X. – 2012-01-29 09:22:12

回答

0

这个事情的作品。请检查此:

<html> 
    <style> 
    .bottomtable{display:block;} 
    .bottomtable .close {background-image:url("http://www.freeimagehosting.net/newuploads/o2gz4.png");background-position: -278px -18px;color: #FFFFFF;display: inline;float: right;height: 10px;margin-right: 5px; margin-top: 10px;position: relative;width: 11px;} 
    .bottomtable .close a {height:7px;width:7px;} 
    .bottomtable .titletext{text-align: right;float: right;margin-right:5px;margin-top:-20px;display:block;} 
    .bottomtable h5{margin:0;padding:0;font-size: 14px;font-weight:normal;display: inline;} 
    .bottomtable ul {display:block;padding:5px;margin:0;} 
    .bottomtable li {list-style-type:none;padding:10px;margin:0;height:75px;display:block;} 
    .bottomtable li a{text-decoration:underline;font-weight:bold;display:block;margin-bottom:5px;} 
    .bottomtable li a span{display:block;text-decoration:underline;font-weight:bold;margin:2px  0 4px;} 
    .bottomtable ul img {display:inline;float:left;margin-top:-2px;margin-right:20px;} 
</style> 
<body> 
    <div class="bottomtable"> 
    <ul> 
     <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div>         </li> 
     <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div> </li> 
     <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div> </li> 
     <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title="">&nbsp;</a>this is some text here..............<div style="clear: right;"></div> </li> 

    </ul> 
    </div> 
</body> 
</html> 

你的背景图片的路径是wrong.You必须指定完整的图像URL是http://www.freeimagehosting.net/newuploads/o2gz4.png

希望这有助于

+0

这件事情是正确的:) – Sabari 2012-01-29 09:53:02

0

这里是工作示例(与您的代码)http://jsfiddle.net/vFLRe/26/

<html> 
<style> 
.bottomtable .close {float:right;margin-right:5px;margin-top:25px;background-image:url('http://www.freeimagehosting.net/o2gz4');background-position:-278px -18px;height:25px;width:25px;display:block;border:1px solid black;} 
.bottomtable .close a {height:25px;width:25px;} 
</style> 
<body> 
<div class="bottomtable"> 
<ul> 
    <li><h5><a href="#">some title</a></h5><a href="javascript://close" class="close" title=""></a>this is some text here..............<div style="clear: right;"></div>      </li> 
</ul> 
    </div> 
    </body> 
</html> 
+0

图像将不会加载。图像路径是错误的 – Sabari 2012-01-29 09:23:58