CSS Line Height,不工作?

时间:2015-01-09 13:16:44

标签: css

尝试获得一个结果,该结果将概述井.outline类,但它的间距太小,当我尝试在.intro类中使用以下代码时。

.intro {
    /** Text Formatting **/
    text-align: center;

    /** Line Spacing **/
    line-height: 3em;
}

如果我没有使用行高,我得到的结果仍然与我的结果相同。

enter image description here

HTML

<div class="intro"> <h4> In my <span class="outline">corner</span> of the internet I make messes that some how turn into code. Don't ask me <span class="outline">how</span>, don't ask me <span class="outline">corner</span>, but things just look good and work well.</h4> </div>

CSS

.outline {
     /** Styling **/
     background: #ff00f6;
     color: #FFF;

     /** Margin & Padding **/
     margin: 3px;
     padding: 6px 8px;
}

1 个答案:

答案 0 :(得分:1)

您提到的代码似乎工作正常。我可以看到一个问题,可能是您的CSS与line-height发生冲突。尝试将!important与css放在一起,如下所述:

.intro {
    /** Text Formatting **/
    text-align: center;

    /** Line Spacing **/
    line-height: 3em !important;
}

Demo