DHTML / js设置带样式的文本内容 [英] DHTML/js set text content w/ styles

查看:75
本文介绍了DHTML / js设置带样式的文本内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新手,优秀的程序员,拿起一些js


我想设置一行文字为

text BOLD more text BOLD text BOLD


我可以在一个< div>中设置javascript文本,但我试过了这个


< div id =" divResText1_id"风格= QUOT; font-family:Arial,sans-serif;

text-align:center; font-size:14px;">搜索返回< / div>

< div id =" divResTextCnt_id"风格= QUOT; font-size:20px; font-weight:bold;">

0< / div>

< div id =" divResText2_id"风格= QUOT; font-size:14px;">结果

< / div>

< div id =" divResTextMiles_id" style =" font-size:20px;

font-weight:bold;"> 20< / div>

< div id =" divResText3_id"风格= QUOT; font-size:14px;">

< / div>

< div id =" divResTextZip_id"风格= QUOT; font-size:20px; font-weight:bold;">

TERM< / div>


当我在Firefox中预览页面时,< div>'创建了< br>还有。


如果这有意义,任何关于如何做的想法??


谢谢

New to this, good programmer, picking up some js

I wanted to set a line of text as
text BOLD more text BOLD text BOLD

I can set the text in javascript in a single <div>, but I tried this

<div id="divResText1_id" style=" font-family: Arial,sans-serif;
text-align: center; font-size: 14px;"> The search returned </div>
<div id="divResTextCnt_id" style=" font-size: 20px; font-weight:bold;">
0 </div>
<div id="divResText2_id" style=" font-size: 14px;"> results within
</div>
<div id="divResTextMiles_id" style="font-size: 20px;
font-weight:bold;"> 20 </div>
<div id="divResText3_id" style=" font-size: 14px;"> chars of
</div>
<div id="divResTextZip_id" style=" font-size: 20px; font-weight:bold;">
TERM </div>

when I previewed the page in Firefox, the <div>''s created <br> also.

If this makes sense, any ideas on how to do this??

thanks

推荐答案

凝视我的水晶球我观察了一个人的军队

< ne **** @ screenlightDOT.com>写在

新闻:ne ************************** @ newsclstr02.news .prodigy.com:
Gazing into my crystal ball I observed one man army
<ne****@screenlightDOT.com> writing in
news:ne**************************@newsclstr02.news .prodigy.com:
新手,优秀的程序员,拿起一些js

我想设置一行文字为
文字BOLD more text BOLD text BOLD

我可以在一个< div>中设置javascript中的文本,但我尝试了这个

< div id =" divResText1_id"风格= QUOT; font-family:Arial,sans-serif;
text-align:
center; font-size:14px;">搜索返回< / div> < div
id =" divResTextCnt_id"风格= QUOT; font-size:20px; font-weight:bold;">
0
< / div> < div id =" divResText2_id"风格= QUOT; font-size:14px;">结果
在< / div>内< div id =" divResTextMiles_id" style =" font-size:20px;
font-weight:bold;"> 20< / div> < div id =" divResText3_id" style ="
font-size:14px;"> < / div>的字符< div
id =" divResTextZip_id"风格= QUOT; font-size:20px; font-weight:bold;">
TERM< / div>
当我在Firefox中预览页面时,< div>创建了< br>还有。

如果这有道理,关于如何做到的任何想法?

谢谢
New to this, good programmer, picking up some js

I wanted to set a line of text as
text BOLD more text BOLD text BOLD

I can set the text in javascript in a single <div>, but I tried this

<div id="divResText1_id" style=" font-family: Arial,sans-serif;
text-align:
center; font-size: 14px;"> The search returned </div> <div
id="divResTextCnt_id" style=" font-size: 20px; font-weight:bold;">
0
</div> <div id="divResText2_id" style=" font-size: 14px;"> results
within </div> <div id="divResTextMiles_id" style="font-size: 20px;
font-weight:bold;"> 20 </div> <div id="divResText3_id" style="
font-size: 14px;"> chars of </div> <div
id="divResTextZip_id" style=" font-size: 20px; font-weight:bold;">
TERM </div>

when I previewed the page in Firefox, the <div>''s created <br> also.

If this makes sense, any ideas on how to do this??

thanks




嗯首先,你有很多不必要的重复。这个

[font-size:20px; font-weight:bold;]可以更改为class =" something"

其中类被定义为.something {font-size:20px; font-

weight:bold;}。


其次,DIV是一个块元素。你应该使用SPAN,这是内联的,

例如。 < span id =" divResTextMiles_id" class =" something"> Data< / span> ;.


第三,不要使用像素字体大小,用户无法调整大小
$ IE中的b $ b,改为使用ems或百分比。


-

Adrienne Boswell
http://www.cavalcade-of-coding.info

请回复群组所以其他人可以分享



Well, in the first place, you have a lot of needless repetition. This
[font-size: 20px; font-weight:bold;] can be changed to class="something"
where the class is defined as .something {font-size: 20px; font-
weight:bold;}.

Second, DIV is a block element. You should be using SPAN, which is inline,
eg. <span id="divResTextMiles_id" class="something">Data</span>.

Third, don''t use pixels for font sizes, they cannot be resized by the user
in IE, use ems or percentages instead.

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


一个人的军队< ne **** @ screenlightDOT.com>写道:
one man army <ne****@screenlightDOT.com> wrote:
这个新手,优秀的程序员,拿起一些js


既然你在这里发帖,你就没有学到区别编程之间

和标记。请先学习一些HTML的基本介绍,然后

请在有HTML问题时返回。

我想设置一行文字为
text BOLD more text BOLD text BOLD


听起来你想_emphasize_。非常强调的HTML标记

是< strong> ...< / strong>。

当我在Firefox中预览页面时,< div>'创建了< br>还有。
New to this, good programmer, picking up some js
Since you post here, you haven''t learned the difference between programming
and markup yet. Please study some elementary introduction to HTML first, and
please return when you have HTML questions.
I wanted to set a line of text as
text BOLD more text BOLD text BOLD
It sounds you would like to _emphasize_. The HTML markup for strong emphasis
is <strong>...</strong>.
when I previewed the page in Firefox, the <div>''s created <br> also.




不,他们不是,但是< div>元素是默认情况下的块,在视觉上是b $ b渲染。


如果你的标记基本上是< div>的汤。标签,你应该首先学习一些

初级HTML介绍。


-

Yucca, http://www.cs.tut.fi/~jkorpela/

有关网页制作的网页: http://www.cs .tut.fi / ~jkorpela / www.html



No, they don''t, but <div> elements are blocks by default, in visual
rendering.

If your markup is essentially a soup of <div> tags, you should study some
elementary introduction to HTML first.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


文章< Xn *********** *****************@69.28.186.121>,

Adrienne Boswell< ar ******** @ sbcglobal.net>写道:
In article <Xn****************************@69.28.186.121>,
Adrienne Boswell <ar********@sbcglobal.net> wrote:
第三,不要使用像素字体大小,用户不能在IE中调整大小,而是使用ems或百分比。
Third, don''t use pixels for font sizes, they cannot be resized by the user
in IE, use ems or percentages instead.




或使用积分。 12pt字体看起来像12pt字体,无论显示器的分辨率是多少?b $ b。另一方面,12px字体显示

取决于显示分辨率。


-A



Or use points. A 12pt font looks like a 12pt font no matter what
resolution the display is. A 12px font, on the other hand, appears
smaller or larger depending on display resolution.

-A


这篇关于DHTML / js设置带样式的文本内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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