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;
),会发生什么?