【发布时间】:2020-06-24 16:00:33
【问题描述】:
我想在内置表格的时事通讯中使用 PHP 设置段落样式。 (白色,填充等...) 但它不起作用。 该段落在变量 $result 中。
这是我正在显示标题的 td 单元格和我正在努力解决的段落:
<td class="resize-main-article" width="49%" align="left" valign="top" bgcolor="#000000">
<a class="whitecolor" style="text-decoration: none; color: #ffffff;" href="<?php echo get_post_permalink($post->ID); ?>" target="_blank">
<p style="color:#ffffff; font-size: 22px; margin-top: 10px; padding: 10px; font-family: 'Times New Roman', Times, serif; margin: 0;" width="100%">
<span style="color: #ed2939;">
<?php echo get_field('overtitle', $post->ID); ?> /
</span>
<?php echo get_the_title($post->ID); ?>
</p>
<?php
$post_content = $post->post_content;
$post_content = apply_filters('the_content', $post_content);
if (preg_match('%^(<p[^>]*>.*?</p>)$%im', $post_content, $regs)) {
$result = $regs[1];
} else {
$result = "";
}
echo "<p style='color:#ffffff; font-size: 14px; padding: 10px; margin: 0;' width='100%'>" . $result . "</p>";
?>
</a>
</td>
Here is what I get (so no stylisation applied...)
Here is the HTML output I get, which gets me a bit confused...
非常感谢您!
【问题讨论】:
-
你的 echo 已经设置了 CSS 样式属性......
-
这不是
<p>元素吗?echo输出的结果 HTML 是什么?它与您的预期有何不同? -
$result是段落的内容,还是内容和周围的段落标签? -
嗨,Martin,是的,这是我真正想应用于 $result 的样式。它是内联编写的,因为我正在表格中构建时事通讯。
-
嗨 jo8691,我认为 $result 还包括标签...
标签: php css css-tables