网络编程
位置:首页>> 网络编程>> 网页设计>> pre标签自动换行

pre标签自动换行

作者:shawn 来源:时光的网记 发布时间:2009-03-13 13:37:00 

标签:HTML,自动换行,标签,pre

pre标签会原样保留HTML内容的格式,可是如果宽度过大会把页面撑坏,这时候需要自动换行来帮忙:

Making preformated text wrap in CSS3, Mozilla, Opera and IEis the tip that let's you use the pre tag to keep the formatting, without cursing yourself when some of the content is too long and doesn't wrap: 

/* Browser specific (not valid) styles to make preformatted text wrap */
pre {
white-space: pre-wrap;       /* css-3 */
white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
white-space: -pre-wrap;      /* Opera 4-6 */
white-space: -o-pre-wrap;    /* Opera 7 */
word-wrap: break-word;       /* Internet Explorer 5.5+ */

父标记最好加个DIV,并设置CSS属性:word-wrap: break-word;white-space : normal;

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com