简体   繁体   English

用HTML呈现空白-Drupal 7?

[英]White space render in html - Drupal 7?

When I used a module i have some problems. 当我使用模块时,我遇到一些问题。 Some white space appeared 出现了一些空白

$content='';
$vocab = vuagame_getVocByName("the_loai_game");
$terms = taxonomy_get_tree($vocab->vid);
foreach ($terms as $term) {
    $content.="<div class='contentBox'>";
    $content.="<div class='contentBoxHeader'>";
    $content.="<a href='/category/".$term->tid."'>".$term->name."</a>";
    $content.="</div>";
    $content.="<table class='gameTable' cellspacing='0' cellpadding='5'>";
    $content.= views_embed_view('home', 'page', $term->tid);
    $content.="</table>";
    $content.="<div class='seemorelink'><a href='/category/".$term->tid."'>Xem thêm</a></div>";
    $content.="</div><br/>";
}
return $content;

and here's the result with inspect element : 这是带有inspect元素的结果:

<div class="contentBox"><div class="contentBoxHeader"><a href="/category/23">18+</a></div>  
"

   "
<table class="gameTable" cellspacing="0" cellpadding="5"><tbody><tr>

Does anyone can find out my trouble? 有人能找出我的麻烦吗? Thanks a lot! 非常感谢!

first, br tag is not a standard now. 首先,br标签现在不是标准。 debug it like this, 像这样调试

1)try the html without the loop first. 1)先尝试不带循环的html。 or break the loop after its first cycle. 或在第一个循环后中断循环。 if white space still exits, replace a href tag with 如果仍有空白,请将href标记替换为

"&lta href='lorum.html'>ispum </a>"

and see if its gone.. there might be a chance of irregular tag open/close 看看它是否消失了。可能会有不规则标签打开/关闭的机会

if still it exists, replace all data objects with just dummy text, if might have some faulty data. 如果仍然存在,请使用伪文本替换所有数据对象(如果可能存在一些错误数据)。

What do you mean by "some white space appeared"? “出现一些空白”是什么意思? You get something displayed, but there is white space underneath it? 您得到显示的东西,但是下面有空白吗?

If that's the case, you could try with adding "clearfix" class to your output and adding this in your css file: 如果是这种情况,您可以尝试在输出中添加“ clearfix”类,并将其添加到css文件中:

.clearfix:after {
    content: "";
    clear: both;
    font-size: 0;
    display: block;
    height: 0;
    visibility: hidden;
}

And yes, this 是的,这
seems unecessary, that could cause the problem too. 似乎不必要,也可能导致问题。

It's seems to be a encoding issue. 这似乎是编码问题。 Try to make sure you're saving your .tpl files with encode UTF-8 尝试确保使用编码的UTF-8保存.tpl文件

This should fix weird spaces. 这应该修复奇怪的空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM