如何动态设置style?

chengfeng 2006-10-03 11:14:52
我建立了一个层
<DIV id="id1" style="BORDER-RIGHT: ........."></DIV>

我希望在程序中动态修改style这个object怎么修改?
由于style中是变量参数,所以直接设置style.top=100这种方法貌似不行
...全文
441 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengfeng 2006-10-08
  • 打赏
  • 举报
回复
up
stou 2006-10-07
  • 打赏
  • 举报
回复
up
飘零雾雨 2006-10-07
  • 打赏
  • 举报
回复
先顶再看!
chengfeng 2006-10-07
  • 打赏
  • 举报
回复
谁能解决这个问题,两百分都给他
http://community.csdn.net/Expert/topic/5062/5062214.xml?temp=.3831751
chengfeng 2006-10-07
  • 打赏
  • 举报
回复
有个关键问题求解
地址:
http://community.csdn.net/Expert/topic/5062/5062214.xml?temp=.3831751
btbtd 2006-10-04
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript">
//<![CDATA[
function cColor(color_){
test.style.color=color_;
}
//]]>
</script>
</head>

<body>
<form name="form1" method="post" action="">
<select name="select" onChange="cColor(this.value)">
<option value="black">black</option>
<option value="blue">blue</option>
<option value="red">red</option>
</select>
</form>
<xmp id="test">
background
[background-color ||background-image ||background-repeat || background-attachment ||background-position]

background-attachment
scroll | fixed

background-color
color | transparent

background-image
url( url ) | none

background-position
[ [percentage | length ]{1,2} | [ [top | center | bottom] || [left | center | right] ] ]

background-repeat
repeat | repeat-x | repeat-y | no-repeat

border
[ border-width ||border-style || color ]

border-collapse
collapse | separate

border-color
color{1,4} | transparent

border-spacing
length length?

border-style
[none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset]{1,4}

border-top border-right border-bottom border-left
[ border-top-width ||border-top-style || color ]

border-top-color border-right-color border-bottom-color border-left-color
color

border-top-style border-right-style border-bottom-style border-left-style
none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset

border-top-width border-right-width border-bottom-width border-left-width
thin | medium | thick | length

border-width
[thin | medium | thick | length]{1,4}

bottom
length | percentage | auto

caption-side
top | bottom | left | right

clear
none | left | right | both

clip
[rect( [length | auto]{4} )] | auto

color
color

content
[ string | url( url ) | counter | attr(attribute-name) | open-quote | close-quote | no-open-quote | no-close-quote ]+

counter-increment
[ identifier integer? ]+ | none

counter-reset
[ identifier integer? ]+ | none

cursor
[ [url( url ) ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help ] ]

direction
ltr | rtl

display
inline | block | list-item | run-in | compact | marker | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none

empty-cells
show | hide

float
left | right | none

font
[ [ font-style || font-variant || font-weight ]? font-size [ / line-height ]? font-family ] | caption | icon | menu | message-box | small-caption | status-bar

font-family
[[ family-name | serif | sans-serif | monospace | cursive | fantasy],]+

font-size
xx-small | x-small | small | medium | large | x-large | xx-large | smaller | larger | length | percentage

font-size-adjust
number | none

font-stretch
normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded

font-style
normal | italic | oblique

font-variant
normal | small-caps

font-weight
normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

height
length | percentage | auto

left
length | percentage | auto

letter-spacing
normal | length

line-height
normal | number | length | percentage

list-style
[ list-style-type || list-style-position || list-style-image ]

list-style-image
url( url ) | none

list-style-position
inside | outside

list-style-type
disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-alpha | lower-latin | upper-alpha | upper-latin | hebrew | armenian | georgian | cjk-ideographic | hiragana | katakana | hiragana-iroha | katakana-iroha | none

margin
[length | percentage | auto]{1,4}

margin-topmargin-right margin-bottom margin-left
length | percentage | auto

marker-offset
length | auto

marks
[ crop || cross ] | none

max-height
length | percentage | none

max-width
length | percentage | none

min-height
length | percentage

min-width
length | percentage

orphans
integer

outline
[ outline-color || outline-style || outline-width ]

outline-color
color | invert

outline-style
none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset

outline-width
thin | medium | thick | length

overflow
visible | hidden | scroll | auto

padding
[length | percentage]{1,4}

padding-top padding-right padding-bottom padding-left
length | percentage

page
identifier | auto

page-break-after
auto | always | avoid | left | right

page-break-before
auto | always | avoid | left | right

page-break-inside
avoid | auto

position
static | relative | absolute | fixed

quotes
[string string]+ | none

right
length | percentage | auto

size
length{1,2} | auto | portrait | landscape

table-layout
auto | fixed

text-align
left | right | center | justify | string

text-decoration
none | [ underline || overline || line-through || blink ]

text-indent
length | percentage

text-shadow
none | [color || length length length? ,]* [color || length length length?]

text-transform
capitalize | uppercase | lowercase | none

top
length | percentage | auto

unicode-bidi
normal | embed | bidi-override

vertical-align
baseline | sub | super | top | text-top | middle | bottom | text-bottom | percentage | length

visibility
visible | hidden | collapse

white-space
normal | pre | nowrap

widows
integer

width
length | percentage | auto

word-spacing
normal | length

z-index
auto | integer
</xmp>
</body>
</html>
xulxqqqq 2006-10-03
  • 打赏
  • 举报
回复
如果是直接添加在实践中的代码使用this.style.top....
engzs 2006-10-03
  • 打赏
  • 举报
回复
document.getElementById("id1").style.top=变量名+"px";
  • 打赏
  • 举报
回复
好几种方法,不过要看你是怎么动态的,根据情况做个选择

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧