我有以下代码:
<div class="outsideDiv">
<div class="element1">Name: </div>
<div class="element2">Something</div>
<div class="element3"> - </div>
<div class="element4">This something is great</div>
</div>
外部div是display:block,所有内部div都显示:inline。在浏览器中,它们都显示在同一行:
Name: Something - This something is great
当我去打印时,4个div显示在这样的单独行上:
Name:
Something
-
This something is great
我很难弄清楚如何让4个内部div在同一行上打印。
答案 0 :(得分:0)
<div class="outsideDiv">
<div class="element1" style="display:inline">Name: </div>
<div class="element2" style="display:inline">Something</div>
<div class="element3" style="display:inline"> - </div>
<div class="element4" style="display:inline">This something is great</div>
</div>
或
将此内容写入print.css:
.element1,.element2, .element3, .element4 {display: inline;}