求大神看看啊
.topList{width:300px; height:180px;border:1px solid #e8e8e8;}
.topList ul{ list-style:none;width:100%;overflow:hidden;float:right;margin:-6px<!--为什么我这里要写负数才能对齐。。求大神帮忙看看!!-->;}
.top em{background:url(http://img1.sycdn.imooc.com//53cf0fa20001d3dc00200032.jpg)no-repeat;color:white;}
em{float:left;width:20px;height:16px;background:url(http://img1.sycdn.imooc.com//53cf0fa20001d3dc00200032.jpg)no-repeat;background-position:bottom;font-family:"Microsoft Yahei";font-size:12px;font-style:normal;text-align:center;}
.topList ul li a{text-decoration:none;color:#333;font-size:12px;}
----------------------------------------------------------------------------------------------
后来想了想是不是em里的块元素把父元素撑开了?可是我设置了float浮动属性
-----------------------------------------------------------------------------
又试验了一下,我之前是设置了overflow的 所以应该是em块把父元素给撑开了,大神有没有来解释一波的?
---------------------------------------------------------------------------------------------------------
*{margin:0;padding:0;}
.topList{width:300px; height:180px;border:1px solid #e8e8e8;}
.topList ul{
margin-left:10px;
}
.topList ul li{ list-style:none;width:100%;float:right;margin-top:12px;}
.top em{background:url(http://img1.sycdn.imooc.com//53cf0fa20001d3dc00200032.jpg)no-repeat;color:white;}
em{float:left;width:20px;height:16px;background:url(http://img1.sycdn.imooc.com//53cf0fa20001d3dc00200032.jpg)no-repeat;background-position:bottom;font-family:"Microsoft Yahei";font-size:12px;font-style:normal;text-align:center;}
.topList ul li a{text-decoration:none;color:#333;font-size:12px;}
改了之后的代码。