【问题标题】:How do I apply css to iframe where the src is PHP?如何将 css 应用于 src 为 PHP 的 iframe?
【发布时间】:2013-11-07 12:12:30
【问题描述】:

我想将 css 应用于我的 html 页面作为 iframe 调用的一段 php 代码:

<iframe src="http://ktibclaims.co.uk/claimStats.php" frameborder="0" width="850" name="frame1" style="color:#ffffff;" ></iframe>

我可以控制 php 文件,但我不是 php 程序员。我要做的就是强制在我的 html 页面上生成的回显文本以正确的字体样式显示,以匹配我页面的其余部分。我在这个网站上尝试了几个关于将内联样式直接应用于 php 的建议,但它似乎不起作用。 php文件只包含php,全文如下:

<?php
require_once('Class.ClaimStats.php');

$claimStats = new ClaimStats();
$totalClaims = $claimStats->getTotalClaimsCount();

echo "We donate &pound;1 to East Coast Truckers for every new claim reported using our     online claims system. There have been " . $totalClaims . " claims so far!";
?>

【问题讨论】:

    标签: php html css iframe echo


    【解决方案1】:

    您也可以在您的 php 文件中放置 HTML 标签!

    所以你可以这样做:

    <?php
        require_once('Class.ClaimStats.php');
    
        $claimStats = new ClaimStats();
        $totalClaims = $claimStats->getTotalClaimsCount();
    ?>
    <span class="cssClass" style="your: inlineStyle;">We donate &pound;1 to East Coast Truckers for every new claim reported using our     online claims system. There have been <?php echo $totalClaims; ?> claims so far!</span>
    

    【讨论】:

      【解决方案2】:

      您可以通过向该 PHP 文件添加一些 CSS 类来设置它的样式,然后在您的样式表中使用这些类。

      <?php
      require_once('Class.ClaimStats.php');
      
      $claimStats = new ClaimStats();
      $totalClaims = $claimStats->getTotalClaimsCount();
      
      echo "<span class='donatestyle' style='color: #FFF;'>We donate &pound;1
          to East Coast Truckers for every new claim reported using our online
          claims system. There have been $totalClaims claims so far!</span>";
      ?>
      

      然后你打电话给&lt;iframe /&gt;

      <style>
      span.donatestyle {color:#F00;}
      </style>
      <iframe src="http://ktibclaims.co.uk/claimStats.php"
              frameborder="0"
              width="850"
              name="frame1"
              style="color:#FFF;">
      </iframe>
      

      【讨论】:

      • 非常感谢 Houssni,你已经解决了我的问题 - 我应该去学习一些 php...
      猜你喜欢
      • 2010-09-18
      • 2014-01-14
      • 1970-01-01
      • 2013-07-04
      • 2015-11-12
      • 1970-01-01
      • 2017-05-21
      • 2011-04-12
      相关资源
      最近更新 更多