如何使用css改变字体大小
pre{font-family:cursive;font-style:italic;font-size:xxx-small}
如何更改pre
字体大小?
pre{font-family:cursive;font-style:italic;font-size:xxx-small}
How to change pre
font size?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
虽然无法直接更改 pre 标记内文本的字体大小,但您始终可以将该文本包装在另一个元素(例如跨度)中并更改该元素的字体大小。
例如(这是内联样式,但如果您愿意,可以将其放入 CSS 中):
While the font-size cannot be changed for text directly inside pre tags, you can always wrap that text in another element (a span, for example) and change the font size of that element.
For example (this is inline-styles, but could be put in CSS if you wanted):
您的问题可能是由于 Courier 被用作默认字体,如果您将 Courier New 设置为首选字体应该没问题。
以下内容在 Firefox 和 Firefox 中都可以正常工作: IE
Your issue is probably due to Courer being used as the default font, if you set Courier New as the preferred font it should be fine.
The following works fine in both Firefox & IE
如果你只需要改变一次字体大小,你可以这样写
If you only need to change the font size once, you can write
看一下这里:
PRE - 预格式化文本
HTML 标签
Take a look here:
PRE - preformatted text
HTML tag
固定
pre
标签上的字体大小的一种解决方案是使用:这可以修复移动浏览器上的字体大小,因为移动浏览器无法准确确定
pre
元素的宽度。来源:移动设备上预标记的字体大小设备变得太大——修复
One solution to fixing font size on
pre
tags is to use:This fixes font sizes on mobile browsers, which cannot accurately determine the width of a
pre
element.Source: Font size of pre tag on mobile devices gets too big – a fix
这是 演示
我我不太清楚为什么我的浏览器(chrome、FF、IE)不同意!
如果我遗漏了什么,请告诉我。
HTML
css
Chrome
Firefox
IE
Here is the Demo
I am not quite sure why my browsers (chrome, FF, IE) doesn't agree!
Please let me know if I am missing something.
HTML
css
Chrome
Firefox
IE
抱歉挖出一个老问题。在高低搜索“为什么浏览器(特别是移动浏览器)渲染
Sorry for digging up an old issue. After searching high and low for "why browsers (specially mobile browsers) renders
<pre>
tags text too small and unreadable", I found as suggested here, changing cssfont-size:
toem
helps. But the gotcha isem
for<pre>
effects size differently on desktop browser then on mobile brower. A clear discrepancy noticeable on android Samsung/Mozilla/Chrome increase in font-size less for the same value ofem
then desktop browsers. The solution to this dilemma is to use%
instead ofem
.The css rule
pre{font-size:200%;}
seems to enlarge<pre>
text more consistently (compare to other texts) on mobile browser as it does on desktop browser.我认为这可能与不同浏览器支持的标准字体有关。在不同的浏览器中尝试您的代码,但请记住 IE 不兼容 W3。
I think it can have something to do with the standard fonts supported by different browsers. Try your code in different browsers but remember IE is not W3 compatible.
我不确定这是否是正确的方法,但这在 Firefox 中对我有用:
I'm not sure if it's the right way to do it, but this worked for me in Firefox: