当前位置:Gxlcms > html代码 > 用一个Div显示大段文本需要做那些设置?_html/css_WEB-ITnose

用一个Div显示大段文本需要做那些设置?_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:82人阅读

在一个小应用中,我需要在页面显示大段文本,文本可能很长,最多有五万字左右。

首先,原有文本格式需要保持,比如空格,空行,回车,TAB等。
其次,一段文本如果较长,需要自动换行,不能把DIV乃至外面的容器撑开。
其三,文本中如果有特殊字符,如引号,HTML代码等也要能正常显示。

目前我再DIV中试用PRE标签1,3倒是可以做到,但第二点不能。
请问我还需要增加什么设置?


回复讨论(解决方案)

是你的样式问题~用了浮动后,最后记得清楚浮动就可以了~

#body_content DIV.down{	background-image: url("../images/content_down.png");	background-repeat: no-repeat;	width:986px;	height:98px;	margin:0;	float:left;}#body_content DIV.down{	background-image: url("../images/content_down.png");	background-repeat: no-repeat;	width:986px;	height:98px;	margin:0;	float:left;}#body_content DIV.center{	background-image: url("../images/content_center.png");	background-repeat: repeat-y;	width:986px;	margin:0;	float:left;}#body_content DIV.up{	background-image: url("../images/content_up.png");	background-repeat: no-repeat;	width: 986px;	height: 105px;	margin: 0;	padding: 0;	float:left;}#area_footer{	width:100%;	height:80px;	padding:50 0 0 0;	clear:both;}

不好意思回复错了~

你的问题,解决方案:
给外层div定宽,文本用p标签写,一个段落用一个p标签;

这样就可以了~

不好意思回复错了~

你的问题,解决方案:
给外层div定宽,文本用p标签写,一个段落用一个p标签;

这样就可以了~

无效啊。

可以用一个隐藏边框,背景透明的textarea显示的,代码如下:


使用$("XXX").value="...";设置值就行。

用textarea可行。

人气教程排行