<li>项目的垂直间距过大</li>

时间:2012-07-31 15:18:43

标签: css html-lists margin padding

Live site.

最右边的Twitter Feed中的<li>项目之间的间距过大,我无法弄清楚原因 - 我找不到任何奇怪的填充或边距问题。

该网站是Wordpress,但这里是呈现的HTML:

<li>
    <h2><a href="#">Recent Tweets</a></h2>
    <div id="twitter-feed">

        <ul>
                                                        <li>
            RT @LollyDaskal: regret is often the result of too many excuses. #leadfromwithin #leadership</li>
                                                        <li>
            What you do in small doses becomes big doses in your life.</li>
                                                        <li>
            RT @ThisIsSethsBlog: Seth's Blog: Two kinds of unique http://t.co/1TJ1Vuf9</li>
                                                        </ul>
    </div><!-- end twitter-feed -->
    <div class="forward-link">
        <p><a href="https://twitter.com/growing_edge"><span style="color:#b8bf33">Follow @Growing_Edge</span></a></p>
    </div><!-- end forward-link -->
</li>

和CSS

#landing-brief #twitter-feed {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 75%;
    line-height: 1.5;
    color: #333333;
    margin-left: -28px;
}

#landing-brief #twitter-feed ul li {
    padding-bottom: 5px;
    height: 200px;
}

#landing-brief .forward-link {
    position: absolute;
    left: 0; 
    bottom: 0;
}

关于导致这种情况的任何想法?

6 个答案:

答案 0 :(得分:1)

#landing-brief #twitter-feed ul li {
    padding-bottom: 5px;
    height: 200px;   <--- here is your problem.
}

使用元素检查器可以查看元素的已定义样式的来源。并且可以帮助您快速发现这样的问题。

答案 1 :(得分:1)

#landing-brief #twitter-feed ul li {
padding-bottom: 5px;
height: 50px;
}

答案 2 :(得分:1)

#landing-brief #twitter-feed ul li上的高度:200px导致此问题。通过完全移除高度使其变小或使其自动化。

不确定您是否意识到这一点,但使用开发者控制台在Safari / Chrome中调试HTML / JS / CSS非常有用,因为您可以实时更改字段并查看浏览器如何呈现它们。 / p>

答案 3 :(得分:1)

这里有两条线路是罪魁祸首。这两个都指定了200px的显式高度。我猜它来自你正在使用的模板。

/* On line 2836 in style.css */
#landing-brief #twitter-feed ul li {
    height: 200px;
    padding-bottom: 5px;
}
/* On line 2814 in style.css */
#landing-brief ul li {
    display: inline-block;
    height: 200px;
    padding-bottom: 20px;
    padding-right: 20px;
    position: relative;
    vertical-align: top;
    width: 250px;
}

要解决此问题,您需要将li块的显式高度覆盖为auto!important;,或者完全删除li的高度。

我是如何得出这个结论的: 我在FireBug中使用了Firefox,并检查了Twitter的个人帖子。在两个样式块上禁用200px高度后,它看起来是正确的。

如果有效,请告诉我: - )

答案 4 :(得分:0)

li的高度为height:200px,更改为height:auto;

答案 5 :(得分:0)

我会说这是你给'#landing-brief#twitter-feed ul li'的高度。试试这个:

#landing-brief #twitter-feed ul li {
padding-bottom: 5px;
height: auto;
}