zoukankan
html css js c++ java
给网友写的控制页面元素高度的代码(js)
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>
无标题页
</
title
>
<
script
type
="text/javascript"
>
function
$(id)
{
return
document.getElementById(id);
}
function
ss()
{
var
wd
=
$(
"
aa
"
);
//
wd= wd.toString().substr(0,3);
for
(
var
i
=
1
;i
<
wd.childNodes.length;i
++
)
{
var
wdH
=
wd.childNodes[i].clientHeight;
//
alert(wdH);
if
(wdH
>
200
)
{
wd.childNodes[i].style.overflow
=
"
hidden
"
;
wd.childNodes[i].style.height
=
"
200px
"
;
//
alert(document.getElementById('aa').style.width);
}
}
}
</
script
>
<
style
>
#aa
{
}
{
clear
:
both
}
#aa div
{
}
{
float
:
left
;
display
:
inline
;
margin-left
:
15px
;
}
.bor
{
}
{
border
:
1px solid #DDDDDD
;
}
</
style
>
</
head
>
<
body
onload
="ss"
>
<
div
id
="aa"
>
<
div
style
="height:10px;"
class
="bor"
>
dsas
</
div
>
<
div
style
="height:400px; background:blue"
class
="bor"
>
雕刻家司克拉
</
div
>
<
div
style
="height:200px; background:#CCCCCC;"
class
="bor"
>
dsafdsaf
</
div
>
<
div
class
="bor"
>
地方啊
</
div
>
<
div
>
单位俄
</
div
>
<
div
class
="bor"
>
的fe
</
div
>
<
div
class
="bor"
>
wewrew
</
div
>
</
div
>
<
br
/>
<
div
onclick
="ss()"
style
="clear:both; border:1px solid #DDDDDD; background:#D5D5D5; 100px;"
>
点击自适应
</
div
>
</
body
>
</
html
>
查看全文
相关阅读:
Working with the RadioButton and CheclBox controls
Simple Data Binding in Silverlight 4.0
Data Binding in Silverlight 4.0
Building a Simple DataGrid in Silverlight 4.0
EXCEL数据导入SQL Server数据库中
正则表达式必知必会
Eclipse插件一次copy多个文件的相对路径路径
走出软件作坊
写在前面的话
[转载]有经验的Java开发者和架构师容易犯的10个错误
原文地址:https://www.cnblogs.com/Longkin/p/1203809.html
最新文章
dell mini9 fluxbox 亮度的调节和 wireless 无线网卡的安装
安装ubuntu server配合fluxbox界面的流程
Android平台值得关注的开源项目
程序员这口饭职业规划解决方案 《转载》
最全的华为面试题java学习
Jquery的一个基本操作实例
JPA(hibernate)开发环境的搭建和一个基本的实例
javascript 重写alert、confirm、prompt 等提示宽框
HQL语句
JqGrid配置
热门文章
Jquery对Jquey元素属性的操作
Myeclipse中修改servlet JSP等模板的方法
java.sql.PreparedStatement
java_struts2自定义拦截器
java对配置文件(XML/properties)的操作
Session跟Cookie有什么关系?假如IE禁止使用Cookie,那Session还有用吗?
Element to Element Binding
C#String.PadLeft函数,文本对齐以及填补解决方案
C#面试题汇总
Working with the TextBox Control In Silverlight 4.0
Copyright © 2011-2022 走看看