在PHP中使用样式化iframe

时间:2018-02-05 05:15:25

标签: php css iframe

如何设置iframe的样式?没什么好看的,只想覆盖浏览器CSS并删除嵌入边框。

foreach ($body_array as $key => $value) {
    if(strpos($value, "www.youtube.com/watch?v=") !== false) {
        $link = preg_split("!&!", $value);
        $value = preg_replace("!watch\?v=!", "embed/", $link[0]);
        $value = "<br><iframe width=\'580\' height=\'315\' src=\'" . $value ."\'></iframe>";
        $body_array[$key] = $value;
    }
}

1 个答案:

答案 0 :(得分:1)

删除边框,您可以在<iframe>标记中使用它:

frameborder="0"

示例

<iframe id="if1" width="100%" height="254" frameborder="0" style="visibility:visible" src="https://www.test.com/"></iframe>

甚至可以添加自定义边框

<iframe id="if1" width="100%" height="254" frameborder="0" style="visibility:visible; border: solid 4px #37474F;" src="https://www.test.com/"></iframe>

修改php

foreach ($body_array as $key => $value) {
if(strpos($value, "www.youtube.com/watch?v=") !== false) {
    $link = preg_split("!&!", $value);
    $value = preg_replace("!watch\?v=!", "embed/", $link[0]);
    $value = "<br><iframe frameborder=\'0\' style=\'visibility:visible; border: solid 4px #37474F;\' width=\'580\' height=\'315\' src=\'" . $value ."\'></iframe>";
    $body_array[$key] = $value;
}
}