【问题标题】:Links on page don't seem to be working页面上的链接似乎不起作用
【发布时间】:2014-07-30 22:04:44
【问题描述】:

首先,我想声明我对 php 很陌生。

我正在使用 XAMPP 开发一个站点,并且我有一些代码可以将 MySQL 数据库中的值吐出到一个 php 页面上。问题是,某些链接似乎不起作用。在浏览器中,它们作为链接不可见,当您将鼠标悬停在它们上方时,光标仍保持为箭头。我检查了源代码,所有似乎都很好。我一直在摆弄根文件夹中的 .htaccess 文件,如果这有什么关系的话。

//This link works just fine
echo "<div class='catname'><a href='".ROOTLINK."$caturl' class='caturllink'>".$catname."</a></div> \n"; 

//These are not working
echo "<div class='cat_post main'> \n
<h1><a href='" . ROOTLINK . $posturl . "' class='cat_post_link' >".$title."</a></h1> \n
<a href='" . ROOTLINK . $posturl . "' ><img src='".ROOTLINK.$photourl."' /></a> \n
<p><a href='" . ROOTLINK . $posturl . "' class='cat_post_link' >".$text."</a></p> \n
<br class='clear' /> <!-- <<<<<<< VERY IMPORTANT --> \n
</div> \n";

ROOTLINK 变量定义为http://localhost/

源代码如下所示:

<div class='catname'><a href='http://localhost/sport' class='caturllink'>SPORT</a></div>

<div class='cat_post main'> 
<h1><a href='http://localhost/sport/20140727120738-commonwealth-games-kick-off.php' class='cat_post_link' >Commonwealth Games kick off</a></h1> 
<a href='http://localhost/sport/20140727120738-commonwealth-games-kick-off.php' ><img src='http://localhost//images/test/phpB206-20140727120738.jpg' /></a> 
<p><a href='http://localhost/sport/20140727120738-commonwealth-games-kick-off.php' class='cat_post_link' >Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus faucibus nunc eleifend nunc sodales tempor. Nullam non enim risus. Praesent vel ante id diam venenatis tincidunt. Vivamus scelerisque, purus ac volutpat blandit, massa nunc feugiat justo, ut iaculis massa nibh at neque. Nunc id quam ut turpis blandit viverra. Nam sagittis, mi ut pulvinar posuere, diam ligula posuere  &hellip;</a></p> 
<br class='clear' /> <!-- <<<<<<< VERY IMPORTANT --> 
</div>

CSS:

div.cat_post.main { display: block; border-bottom:2px solid #BE420E; padding-bottom: 15px; margin-bottom: 10px; }
div.cat_post.main img { width: 300px; height: 169px; background-color: #AAA; float: left; margin-right:10px;} 
div.cat_post.main p { float: right; width: 300px; height: 169px; margin: 0 10px 0; }
a.cat_post_link { color: #666666; }

.catname { background-color: #FFF68F; font-size: 24px; color: #BE420E;  margin-bottom: 10px; padding: 5px 5px 5px 10px; font-weight: bold;}
.caturllink { background: inherit; text-transform: uppercase; }

【问题讨论】:

  • 也许你应该展示你的 CSS。听起来它与此有关,当然不是 htaccess。 PHP 和 MySQL 都不是。
  • 那是 PHP 输出的 exact HTML 吗?因为那是有效且有效的 HTML。如果我将它复制到一个空的 html 文件中,所有链接都可以正常工作(当然,目标位置在我的本地主机上不存在)。在这种情况下,这是客户端问题(可能由 CSS 或 JavaScript 或其他原因引起),而不是服务器端问题(即 PHP 或 .htaccess 问题)。
  • 这么多的 CSS 够用吗? @putvande
  • “问题是,某些链接似乎无法正常工作。在浏览器中它们不显示为链接”您的意思是什么?它们是可点击的吗?他们是否将您带到正确的页面? “不作为链接可见”是什么意思?
  • 如果它们在页面加载时可以点击,但在“完全”加载时不能点击,则可能是 Javascript 问题。作为you can see,您发布的代码工作正常,并且链接是可点击的。你有其他事情发生,你需要调试它。如果您不能比目前为止更多地缩小问题范围,我们将无济于事。我还将从您的问题中删除一些不太可能的标签;例如,这与 MySQL 无关。

标签: javascript html css


【解决方案1】:

我意识到侧边栏中的结束 &lt;/div&gt; 标签丢失了,一旦我重新添加它,一切都恢复正常。简单,但有害。

【讨论】:

  • 感谢大家的耐心等待。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-24
  • 2014-03-25
  • 1970-01-01
相关资源
最近更新 更多