dongwei1855 2016-03-17 14:45 采纳率: 0%
浏览 902
已采纳

你如何使用CSS在PHP中设置HTML样式?

I need to be able to style some simple HTML I've written in PHP

PHP:

if ($result-> num_rows> 0) {
  readfile("ViewReturn.html");
  while($row = $result-> fetch_assoc()) {
    echo "Bird Name: ".$row["pageLink"]. "<br><br>";
  }
} else {
  echo "0 results";
}

I would like to be able to style the HTML I'm outputting at "birdname" and "page link" because it doesn't sit very well on the page. Does anyone know how to go about doing this?

  • 写回答

4条回答 默认 最新

  • doune1000 2016-03-17 14:51
    关注

    You could add the bird name in a <span> with a class and style the class using CSS.

    Do it as below

     echo "<span class='birdname'>Bird Name: ".$row["pageLink"]. "</span><br><br>";
    

    ie, replace your code as

    if ($result-> num_rows> 0) {
      readfile("ViewReturn.html");
      while($row = $result-> fetch_assoc()) {
        echo "<span class='birdname'>Bird Name: ".$row["pageLink"]. "</span><br><br>";
      }
    } else {
      echo "0 results";
    }
    

    and in CSS, add

    .birdname{
       color:red;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?