将文本定位在其他文本之上

时间:2014-08-22 12:24:27

标签: html5 css3

我希望将文本片段放在同一行的另一部分之上:

<div>Th<div class="ac">Am</div>is is an ex<div class="ac">E</div>ample line</div>

会显示

  Am         E
This is an example line

1 个答案:

答案 0 :(得分:1)

您应该可以使用以下设置执行此操作:

.ac {
    position:relative; /*relative to the position it had in the line*/
    top:-1em; /*move up exactly one line*/
    width:0px; /*don't keep the width in the original line*/
    display:inline-block; /*dont add a line break*/
}
body {
    font-family:monospace
}

http://jsfiddle.net/kf2rb83x/