文本背景样式

时间:2014-07-11 12:02:32

标签: html css

我正在尝试调整文本背景颜色的大小以使其合理,尽管文本不是。

http://jsfiddle.net/6kLp9/5/

HTML

 <h2>
     <span>content1<br>
           content2 content3<br>
           content4 content5 content6
     </span>
</h2>

CSS

 h2 {
    line-height: 1.5em;
    color: aqua;
    font-size: 1em;
    right: 100%;
    top: 8em;
    width: 40%;
    z-index: 10;
    text-align:left;
    vertical-align: bottom;
    }

 h2 span {
    background-color:black;
    opacity:0.7;}

1 个答案:

答案 0 :(得分:1)

在你的css中添加以下内容:

h2 {
    background-color:black;
}
h2 span {     
    line-height:1.5em;
}

删除

text-align:center

因为你想要文本左对齐。

此处更新了Fiddle

相关问题