PHP - 更改HTML输出的字体大小 [英] PHP - Changing the font sizes of HTML output

查看:82
本文介绍了PHP - 更改HTML输出的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




对大多数人来说这可能很简单,但我有一个基于PHP的网站,我想更改字体(输出的HTML)和我''我真的很挣扎!这是我的代码片段:

展开 | 选择 | Wrap | 行号

解决方案

您遇到的问题是因为表格外的字体大小更改不会影响表格单元格内的字体大小。如果要使用< font ...>更改字体大小标签你必须在每个表格单元格中放置一个。这使得HTML变得非常混乱。


然而,好消息是现在有一种更好的方式可以使所有以下标签都被删除


< font>

< basefont>

< b>

< i>


而不是你应该尝试使用css(或< strong>和< em>标签代替< b>和< i>)。使用css,您可以将字体大小和样式应用于所有表格单元格,并在文件顶部放置1个小部分数据。尝试将此添加到您的输出中(我只输入< html>,< head>和< body>标记,以便您可以告诉它应该在文件中的位置)


[html]

< html>

< head>

< style>

body {

字体大小:100%;

}


td,th {

字体-size:60%

}

< style>

< / head>

< body> ;


此处所有正常输出


< / body>

< / html>

[/ html]


将正文文本大小设置为100%只是让所有浏览器以更相似的方式行事的技巧。


您可以在 www.w3schools.com找到有关CSS的所有信息。


我还注意到在你的html中你打开字体标签然后是表格标签但是你关闭字体标签是关闭表标签。这是不好的形式,标签应该嵌套,并将它们交叉。


您可以使用位于
的W3C提供的验证器检查您的HTML。 > http://validator.w3.org


你是一个救生员!万分感谢!


还有一个问题。我在设置表格宽度和高度方面遇到了类似的问题,我可以在同一个css文件中输入这些属性吗?如果是这样的话?


再次感谢,非常感谢。

Hi,

This is probably really simple to most of you but I have a PHP based website that I want to change the font (of the outputted HTML) and I''m really struggling! Here is a snippet of my code:

Expand|Select|Wrap|Line Numbers

解决方案

The problem you are having is because font size changes outside a table do not effect the font sizes inside the table cells. If you want to change the font sizes using the <font ... > tag you have to put one inside every table cell. This makes for very messy HTML.

However the good news is that there is now a better way all of the following tags are depricated

<font>
<basefont>
<b>
<i>

instead you should try using css (or the <strong> and <em> tags in place of <b> and <i>). With css you can applied a font size and style to all table cells with 1 small section of data at the top of you file. Try adding this to your output (I put in the <html>, <head> and <body> tags only so that you can tell where it should go in the file)

[html]
<html>
<head>
<style>
body {
font-size: 100%;
}

td, th {
font-size: 60%
}
<style>
</head>
<body>

All your normal output in here

</body>
</html>
[/html]

Setting body text size to 100% is just a trick to get all browsers to act in a more similar manor.

You can find out all you need to about CSS at www.w3schools.com

I also notice that in your html you open the font tag then the table tag but then you close the font tag before closing the table tag. This is bad form, tags should be nested with crossing them over like that.

You can get your HTML checked by using the validator provided by W3C located at

http://validator.w3.org


You are a life saver! Thanks a million!


One more quick question. I''m having a similar problem with setting table width and height, can I enter these properties in the same css file and if so how?

Thanks again, very much appreciated.


这篇关于PHP - 更改HTML输出的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆