所有课题
网站首页
栏目列表
当前位置:
首页
>>
化学家园
>>
习题下载
>>
中考模拟
>>文章内容
用JavaScript控制div的float属性
发布时间:2008-12-26 点击: 来源:中国IT人才网 作者:will2011
用JavaScript控制div的float属*,代*如下:
Source Code to Run
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://{域名已经过期}/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://{域名已经过期}/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>用JavaScript控制CSS的float属*--中国IT人才网!IT求职,IT招聘</title> <style type="text/css"> /*基本样式定义开始*/ *{ margin:0; padding:0;} body { font-size:12px; line-height:150%;} td{ height:22px; padding:6px;} a{font-size:12px; color:#000000; text-decoration:none;} a:link{color: #000000;} a:visited{color: #000000;} a:hover{text-decoration: underline; color:#000000;} a:active{color:#000000;} img{border:none;} ul,li{ list-style-type:none;} /*基本样式定义完成*/ #demo{text-align:center; margin-top:30px;} </style> </head> <script type="text/javascript"> function divFloatRight(e) { e.style.backgroundColor = "#ff0000"; e.style.styleFloat = "right";//IE e.style.cssFloat = "right";//firefox and others explorer } function divFloatLeft(e) { e.style.backgroundColor = "transparent"; e.style.styleFloat = "left"; e.style.cssFloat = "left"; } </script> <body> <div id="demo" style="border:dashed 1px #000000; cursor:pointer;" onmousemove="divFloatRight(this);" onclick="divFloatLeft(this);">用JavaScript控制div的float属*,onmousemove~float:right,onclick~float:left。</div> </body> </html>
[可先修改部分代* 再运行查看效果]
关闭窗口
打印文档
附件:
主办单位:常州市新北区奔牛初级中学
苏ICP备10201501号-3
地址:常州市新北区奔牛中天南路61号
技术支持:新北区教师发展中心、
常州万兆网络科技有限公司
访问统计