如何更改回显的字体大小? [已关闭]

问题描述 投票:0回答:2

我需要知道如何更改回显输出的字体大小。我已经在代码中使用了不同的字体颜色,这对于像我这样的菜鸟来说变得更加复杂。回声应为黑色,大小约为 150%。请写出它的完整代码,如果有人能教我如何做到这一点,那将真正帮助我。谢谢。

<?php
srand (microtime()*10000);
$f_contents = file ("secretnet.txt");
$line = $f_contents[array_rand ($f_contents)];
echo "<font color='black'>$line</font>";
?>
html css font-size
2个回答
0
投票

在你的 php 文件中:

<?php
srand (microtime()*10000);
$f_contents = file ("secretnet.txt");
$line = $f_contents[array_rand ($f_contents)];
echo "<div class='awesomeText'>$line</div>";
?>

在您的文件中:style.css,需要将其作为链接资源包含在页面顶部。

.awesomeText {
    color: #000;
    font-size: 150%;
}

这是一个快速示例:http://jsfiddle.net/qro9r54t/


0
投票

这应该可以解决问题,但就像其他人提到的那样,使用 CSS(最好带有样式表)将是理想的选择。

<?php
srand (microtime()*10000);
$f_contents = file ("secretnet.txt");
$line = $f_contents[array_rand ($f_contents)];
echo "<div style='font-size:150%; color:#000000'>" .  $line . "</div>";
?>

如果您使用样式表,它看起来会像这样。如果您需要这些方面的帮助,我建议您在网站的 CSS 部分发布。

<?php
srand (microtime()*10000);
$f_contents = file ("secretnet.txt");
$line = $f_contents[array_rand ($f_contents)];
echo "<div class='your_class_name_here'>" .  $line . "</div>";
?>
© www.soinside.com 2019 - 2025. All rights reserved.