2012-11-25 42 views
1

这是一个小问题。我试过摆弄它,但没有运气。所以基本上我想在中心,但在酒吧的最后拿到这个小图标:CSS定位HTML图标

http://puu.sh/1u4SI

但是,如果我把在CSS top: 5px;它会显示此:http://puu.sh/1u4T1

该代码是这样的:

<style> 
a.news-item, a.box-link { 
display: block; 
padding: 5px; 
margin: 0 0 2px -5px; 
background: #E9E9E9; 
-moz-border-radius: 3px; 
-webkit-border-radius: 3px; 
border-radius: 3px; 
color: #8C8C8C; 
text-decoration: none; 
font-weight: normal; 
} 

a.news-item { 
width: 100%; 
height: 36px; 
color: #8C8C8C; 
} 


a.box-link { 
width: 230px; 
padding: 5px; 
height: 24px; 
overflow: hidden; 
color: #8C8C8C; 
} 

a.news-item span.title {  
font-size: 18px; 
} 


a.news-item:last-child, a.box-link:last-child { 
margin: 0 0 0 -3px;  
} 

a.news-item:hover, a.box-link:hover { 
background: #E2E2E2; 
} 

.pane .delete { 
position: absolute;     
right: 28px; 
top: 5px; 
cursor: pointer; 
} 

.pane { 
padding: 3px; 
} 
</style> 

<script type="text/javascript"> 
$(document).ready(function(){     
$(".pane .delete").click(function(){ 
    $(this).parents(".pane").animate({ 
     opacity: 0 
    }, 'slow', function(){ 
     $(this).slideUp(); 
    }); 
}); 

}); 
</script> 


    <h2>Topher's Articles</h2> 

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><br /> 


    <div class="pane"> 
    <img src="../real/_lib/_image/minus.png" alt="delete" class="delete" />    
    <a class="news-item" href="#/media/<?php echo $row['id'] ?>.<?php echo str_replace(" ", "-", $row['news_title']); ?>">   
    <span class="title"><p><?php echo $row['news_title'] ?> <font size="2"> &raquo; <?php echo $row['news_date'] ?></font></p></span>     
    </a> 
    </div>   

</body> 
</html> 
+0

嘿,现在是10:22上午。 SCNR。你应该减少大量的代码。 – rekire

回答

1

你尝试设置padding-top instad的top

+0

ohhhh耶稣..它的工作..这是超级简单..哇..谢谢你! – TrippedStackers

+1

不客气。不要忘记接受这个答案;-) – rekire

1

我想你需要使用margin-top而不是top

如果要使top以相对坐标工作,则需要将position: relative应用于其容器。