在 XML 中在文本和 iframe 之间放置空格时遇到麻烦



我有一个XML文件,其中包含以下相关部分

<postText>
<![CDATA[text <br>
stuff<br />
<iframe width='560' height='349' src='http://www.youtube.com/embed/video'
 frameborder='0' marginheight='40px' allowfullscreen></iframe>]]>
</postText>

使用 php simplexmlloader,我可以打印这个项目,但是尽管有
标签和边距高度变量,但文本和 youtube 视频的顶部之间没有空格。

我的猜测是,您可能误解了属性marginheight

marginheight 属性定义text <br>stuff<br /><iframe>之间的间距,而是定义框架内容与框架的上边距和下边距之间的空间(即在 iframe 内部)。

在文本和 iframe 元素之间设置垂直间距的一种方法是将<iframe>包装在<div>中,并为<div>定义一个margin-top

<postText>
<![CDATA[text <br>
stuff<br /><div style="margin-top: 40px;">
<iframe width='560' height='349' src='http://www.youtube.com/embed/video'
 frameborder='0' marginheight='40px' allowfullscreen></iframe></div>]]>
</postText>

最新更新