php 代码中的空格导致 html 在页面上移动
whitespace in php code causing html to move on page
我的分页脚本是服务器端的,要求 html 写在 php 中。当您单击某些按钮时,整行向右移动 and/or 左移一个字符 space 或两个。我已经看了这个一个多小时了,我想把枪放在嘴里,一个字符 space 一个字符 space 仔细检查它,我很确定它与空白有关。
我不指望这里的任何人会通过它来寻找 space 但我想知道是否有人处理过这个问题并且可以推荐在哪里寻找可能是白色的 space移动我的行 and/or 如果有任何东西可以删除所有白色 space 而不会影响代码的完整性。
$prevlink = ($page > 1)?'<a href="?page=1" title="First page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><a href="?page='.($page - 1).'"title="Previous page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span> <span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span>';
// The "forward" link
$nextlink = ($page < $pages) ? '<a href="?page='.($page + 1).'"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page='.$pages.'"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span><span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right"aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span>';
// The "back" link
$prevlink = ($page > 1)?'<a href="?page=1" title="First page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><a href="?page='.($page - 1).'"title="Previous page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span> <span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span>';
// The "forward" link
$nextlink = ($page < $pages) ? '<a href="?page='.($page + 1).'"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page='.$pages.'"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span><span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right"aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span>';
// Display the paging information
echo '<div id="paging">',$prevlink,'<p>Listing',$page,'of',$pages,'</p>',$nextlink,'</div>';
来源:
页面已加载:
<div id="paging"><span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span> <span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span><p>Listing1of31</p><a href="?page=2"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page=31"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a></div><div class="edit_listing" style="overflow:hidden;">
单击一次进入下一页会使该行向右移动一次。这是点击后的来源:
<div id="paging"><a href="?page=1" title="First page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><a href="?page=1"title="Previous page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><p>Listing2of31</p><a href="?page=3"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page=31"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a></div><div class="edit_listing" style="overflow:hidden;">
第一个示例有一个跨度,而第二个示例没有,很可能 CSS 正在应用于该跨度或其中的元素。
我的分页脚本是服务器端的,要求 html 写在 php 中。当您单击某些按钮时,整行向右移动 and/or 左移一个字符 space 或两个。我已经看了这个一个多小时了,我想把枪放在嘴里,一个字符 space 一个字符 space 仔细检查它,我很确定它与空白有关。
我不指望这里的任何人会通过它来寻找 space 但我想知道是否有人处理过这个问题并且可以推荐在哪里寻找可能是白色的 space移动我的行 and/or 如果有任何东西可以删除所有白色 space 而不会影响代码的完整性。
$prevlink = ($page > 1)?'<a href="?page=1" title="First page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><a href="?page='.($page - 1).'"title="Previous page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span> <span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span>';
// The "forward" link
$nextlink = ($page < $pages) ? '<a href="?page='.($page + 1).'"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page='.$pages.'"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span><span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right"aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span>';
// The "back" link
$prevlink = ($page > 1)?'<a href="?page=1" title="First page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><a href="?page='.($page - 1).'"title="Previous page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span> <span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span>';
// The "forward" link
$nextlink = ($page < $pages) ? '<a href="?page='.($page + 1).'"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page='.$pages.'"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a>':'<span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span><span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-right"aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></span>';
// Display the paging information
echo '<div id="paging">',$prevlink,'<p>Listing',$page,'of',$pages,'</p>',$nextlink,'</div>';
来源:
页面已加载:
<div id="paging"><span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span> <span class="disabled"><button type="button" class="btn btn-default btn-lg disabled"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></span><p>Listing1of31</p><a href="?page=2"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page=31"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a></div><div class="edit_listing" style="overflow:hidden;">
单击一次进入下一页会使该行向右移动一次。这是点击后的来源:
<div id="paging"><a href="?page=1" title="First page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><a href="?page=1"title="Previous page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></button></a><p>Listing2of31</p><a href="?page=3"title="Next page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a><a href="?page=31"title="Last page"><button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button></a></div><div class="edit_listing" style="overflow:hidden;">
第一个示例有一个跨度,而第二个示例没有,很可能 CSS 正在应用于该跨度或其中的元素。