Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用内联块在dompdf中的元素下方添加空间_Php_Html_Css_Dompdf - Fatal编程技术网

Php 使用内联块在dompdf中的元素下方添加空间

Php 使用内联块在dompdf中的元素下方添加空间,php,html,css,dompdf,Php,Html,Css,Dompdf,当有两个或两个以上的元素具有显示:内联块时,这些元素在呈现为pdf格式后,在下面显示一个边距: <div style="background-color:pink;"> <div style="background-color:red;float:left;width:25%;">Hello</div> <div style="background-color:orange;float:left;width:25%;">Hello&

当有两个或两个以上的元素具有
显示:内联块
时,这些元素在呈现为pdf格式后,在下面显示一个边距:

<div style="background-color:pink;">
    <div style="background-color:red;float:left;width:25%;">Hello</div>
    <div style="background-color:orange;float:left;width:25%;">Hello</div>
    <div style="background-color:yellow;float:left;width:25%;">Hello</div>
    <div style="background-color:green;float:left;width:25%;position:relative;">
        <div style="background-color:red;display:inline-block;width:25%;">Hello</div><!--
        --><div style="background-color:orange;display:inline-block;width:25%;">Hello</div>
    </div>
</div>

你好
你好
你好
你好

但当只有一个时,它显示良好:

<div style="background-color:pink;">
    <div style="background-color:red;float:left;width:25%;">Hello</div>
    <div style="background-color:orange;float:left;width:25%;">Hello</div>
    <div style="background-color:yellow;float:left;width:25%;">Hello</div>
    <div style="background-color:green;float:left;width:25%;position:relative;">
        <div style="background-color:red;display:inline-block;width:25%;">Hello</div>
    </div>
</div>

你好
你好
你好
你好

已经尝试在同级元素上使用
clear:两者
,并将其作为
内联块
元素的包装器,但这只会导致它位于绿色div下面

也尝试过使用
float:left
,就像其父元素一样,但使用它会导致元素重叠


是否有其他方法使浮动元素的子元素水平对齐?

如注释中所述,
内联块
的默认样式为
垂直对齐:基线
,这可能导致定位问题。将
垂直对齐:顶部
垂直对齐:底部
添加到所有
内联块
以解决此问题。

如果添加一些css以删除边距(例如
边距:0;
),会发生什么?