让CSS通过PHP与HTML交互

时间:2017-11-20 10:49:25

标签: php css html5

以下是我的PHP代码:

$heads = array();
$heads[0] = "<p class='ourmoto'>Your camera solutions...</p>";
$heads[1] = "<a href='index.html'><img id='rentals' src='images/rentalsnew2.jpg' alt='GroupLogo' /></a>";
$heads[2] = "<p class='ourmoto'>...Your camera solutions</p>";

for ($i = 0; $i<3; $i++){
  echo"<p>$heads[$i]</p>";  
}

CSS:

.ourmoto {
    font-style:oblique;
    font-size:30px;
    display:inline;
    margin: 0 auto;
}

据我所知,echo应该在引用中以字符串形式打印出来的内容,即使它的HTML标签也是如此。它设法打印HTML但CSS不适用于它。我做错了什么?

谢谢!

1 个答案:

答案 0 :(得分:-3)

遍历每个脑袋,用课堂回声:

foreach ($heads as $head)
  echo "<p class='ourmoto'>{$head}</p>";  
}