html - 更改 PHP Echo 输出的字体大小

标签 html css font-size

我一直在玩弄 image upload example from W3Schools ,但我想更改上传后出现的输出的字体大小。我试过用 id="up_finished"div 标签包围 php 代码,并制作了这样的 CSS 代码:

#up_finished {
    font-size: 10px;
}

我的代码是这样的:

<form>
    <center>
        <div id="upfinished">
            <?php
                $img_org_name = $_FILES["file"]["name"];
                $img_ext = "." . pathinfo($img_org_name, PATHINFO_EXTENSION);
                $img_name = generateKey() . $img_ext;
                $img_type = $_FILES["file"]["type"];
                $img_error = $_FILES["file"]["error"];
                $img_size = $_FILES["file"]["size"];
                $img_tmp = $_FILES["file"]["tmp_name"];

                if ((($img_type == "image/gif")
                    || ($img_type == "image/png")
                    || ($img_type == "image/jpeg")
                    || ($img_type == "image/tiff")
                    || ($img_type == "image/bmp")
                    || ($img_type == "image/pjpeg"))
                    && ($img_size < 4194304))
                {
                    if ($img_error > 0)
                    {
                        echo "Error: " . $img_error . "<br />";
                    } else {
                        echo "Upload: " . $img_name . "<br />";
                        // echo "Type: " . $img_type . "<br />";
                        echo "Size: " . round(($img_size / 1048576), 2) . " Mb<br />";

                        if (file_exists("img/" . $img_name))
                        {
                            echo $img_name . " already exists. ";
                        } else {
                            move_uploaded_file($img_tmp, "img/" . $img_name);
                            echo "Stored in: " . "img/" . $img_name;
                        }
                    }
                } else {
                    echo "Error! Try re-submiting the image <br />
                         Error ID: " . $img_error . "<br />";
                }

                function generateKey()
                {
                    $chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
                    srand((double)microtime()*1000000); 
                    $i = 0; 
                    $pass = '' ; 

                    while ($i <= 3)
                    { 
                        $num = rand() % 33; 
                        $tmp = substr($chars, $num, 1); 
                        $pass = $pass . $tmp; 
                        $i++; 
                    } 
                    return $pass;
                }
            ?>
        </div>
    </center>
</form>

但是什么也没发生。我该怎么办?

最佳答案

@Nathan Campos:如果下面的代码示例也不起作用,则可能是其他原因覆盖了您的字体大小;另一种样式表设置或很可能是浏览器设置。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>questions/5285643</title>

<style type="text/css">
<!--
#up_finished {
    font-size: 10px;
}
#up_finished span {
    /* for demonstration purposes */
    font-size: 16px;
}
// -->
</style>
</head>

<body>

<form>
    <center>
        <div id="up_finished">
            <?php
            /* Replace this with your PHP code */
            ?>
            <br />Filler text which should be
            10px large<br />
            <span>Filler text which should be
            16px large</span>
        </div>
    </center>
</form>

</body>
</html>

jsFiddle:http://jsfiddle.net/phF9b/查看运行中的代码。

关于html - 更改 PHP Echo 输出的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5285643/

相关文章:

jquery - 如果使用 css 超过 100%,则使 div 子 pre 元素全部具有相同的宽度

java - 我想更改文本流或标签中的字体大小

delphi - 更改所有对话框的整个字体名称(第 2 部分)

jquery - Bootstrap 中带页脚的全高侧边栏

javascript - 使用 php 和 jquery 的重音问题

css - 如何使用 CSS 为子 div 设置相同的高度

css - Bootstrap 响应式大屏幕

html - 在悬停状态下重叠 anchor

html - 将工具提示放在按钮上方的左侧而不是右侧

html - 如何使用基础图标更改列表项样式?