【问题标题】:Echoing a MySQL string with text, then style it with CSS用文本回显 MySQL 字符串,然后用 CSS 设置样式
【发布时间】:2014-01-28 02:59:14
【问题描述】:

我已经在互联网上寻找了一段时间,想看看如何制作我的 echo'd 字符串。 我已经能够用例子弥补很多东西。但是当涉及到我自己的代码时,我无法做到这一点,即使我做的事情完全一样。

这是我的回声 PHP:

echo "<div id=\"suggestions\"><h1> Our suggestions for you: </h1>";
$i = 1;
while($row = mysqli_fetch_array($frequency))
{
$query = "SELECT country FROM project.countries WHERE countryID LIKE (".$row['countryID'].")";

$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$countrysuggestion = $row['country'];

echo "<h2>Suggestion no.".$i." is: ".$countrysuggestion."!</h2>";
$i = $i + 1;
}
echo "</div>";

那么这是我们的样式CSS代码:

<style type=”text/css”>
#suggestions{
visibility: hidden;
}
</style>

在我们的网站上,这种回声的“东西”不会隐形。有谁能帮帮我们吗?

【问题讨论】:

  • 您确定mysqli 正在获取任何数据吗??
  • 所以它正在回显信息但没有将 CSS 类应用于 suggestions?
  • 你试过 display:none;
  • 我怀疑这会产生什么影响,但type="text/css" 中有有趣的引号字符。
  • @wickywills 这会有所作为。这就是答案。

标签: php html mysql css hidden


【解决方案1】:

假设下面是你的inline-css

<style type=”text/css”>
  #suggestions{
    visibility: hidden;
  }
</style>

quotesvisibility: hidden; 更改为

     <style type="text/css"> /* <= notice quote in this line, these are 
apostrophes in yours, this makes a huge difference */
        #suggestions{
           display: none; /*notice none here*/
        }
      </style>

加法编辑

visibility: hidden 隐藏了元素,但它仍然占用布局中的空间。

display: none 从文档中完全删除元素。它不占用任何空间,即使它的 HTML 仍在源代码中。

【讨论】:

  • visibility:none; 是一个合适的值吗?
  • @GhostEcho:完美的搭档……那是我的错字……在您发表评论后在我的答案中添加了一个编辑……+1 :)
  • visibility: none; 没用。幸运的是,错误出现在引号中!非常感谢。现在我可以尝试使用 jQuery 将其设置为可见!
  • @RichardDirven : visibility: none; 是我的错字...请参阅我的回答中的 Addition edit 部分! :)
【解决方案2】:

尝试如下内联CSS

echo "<div id='suggestions' style='visibility: hidden;'>
      <h1> Our suggestions for you: </h1>";
echo "</div>";

或更改样式标签中的引号

 <style type="text/css">
      #suggestions{
           visibility: hidden;
      }
 </style>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多