Html 更改PHP Echo输出的字体大小
我一直在使用,但我想更改上传后显示的输出的字体大小。我试着用带有Html 更改PHP Echo输出的字体大小,html,css,font-size,Html,Css,Font Size,我一直在使用,但我想更改上传后显示的输出的字体大小。我试着用带有id=“up\u finished”的div标记包围php代码,并生成如下CSS代码: #up_finished { font-size: 10px; } <form> <center> <div id="upfinished"> <?php $img_org_name = $_FILES["file"
id=“up\u 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>
我的代码如下:
#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>
问题/5285643
填充文本应为
10px大的
填充文本应为
16px大
jsFiddle:查看正在运行的代码。@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>
问题/5285643
填充文本应为
10px大的
填充文本应为
16px大
jsFiddle:查看实际的代码。这样或类似的方法应该可以工作。你能展示完整的代码吗?你是否添加了其他标签/代码,使之成为一个真正的HTML页面,而不仅仅是一个输出文本的PHP脚本?(像doctype声明、html/body标记等)不允许在id属性中使用unserscrore,也许你的浏览器忽略了CSS规则?在Firebug或Chrome inspector中检查CSS规则是什么applied@freddyK.:允许在#ids中加下划线:@freddy K.:这篇文章是2001年写的,当时CSS2没有得到广泛支持。除非你仍然支持Netscape浏览器或IE5,否则它就不再相关了。那样应该可以。你能展示完整的代码吗?你是否添加了其他标签/代码,使之成为一个真正的HTML页面,而不仅仅是一个输出文本的PHP脚本?(像doctype声明、html/body标记等)不允许在id属性中使用unserscrore,也许你的浏览器忽略了CSS规则?在Firebug或Chrome inspector中检查CSS规则是什么applied@freddyK.:允许在#ids中加下划线:@freddy K.:这篇文章是2001年写的,当时CSS2没有得到广泛支持。除非您仍然支持Netscape浏览器或IE5,否则它不再相关。