使div永久高度&如果内容超出限制,则使其可滚动 [英] make div permanent height & width and make it scrollable if content exceeds the limit
本文介绍了使div永久高度&如果内容超出限制,则使其可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< !DOCTYPE html >
< html >
< head >
< script src = http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/ jquery.min.js > < / script >
< script >
函数 CreateComponents(){
for ( var i = < span class =code-digit> 0 ; i< 10; i ++)
{
$( #TreeView)。append( < ul id ='Comp + i + '>< input type ='checkbox'id ='Component + i + 'name ='Component + i + 'onchange ='GetMemos(\Comp + i + \,\ + i + \);'/>< a> + i + < / a>< / ul>);
}
}
function GetMemos(Tagid,data){
if ($( # + Tagid + li)。length == 0 ){
$( # + Tagid).addClass(' parent');
for ( var i = 11 ; i< 20; i ++){
$( # + Tagid + )。append( < span class =code-string>< li style ='padding-removed20px'>< input type ='checkbox'id ='备注 + i + 'name ='备注 + i + '/>< a> + i + < / a> < / li>)
}
}
}
< / script >
< / head >
< < span class =code-leadattribute> body >
< div id = TreeView style = width:50%; border:2px solid; height:75%; overflow:hidden; > < / div >
< 输入 type = 按钮 value = 创建组件 onclick = CreateComponents(); / >
< / body >
< / html >
当我点击Create Component按钮时,我会添加一些ul并在每个ul的复选框上添加一些li。
我想做的是使div大小永久,宽度为50%,高度为50%。
任何人都可以帮助我
提前致谢
解决方案
( #TreeView)。append( < ul id ='Comp + i + '>< input type ='checkbox'id ='Component + i + ' name ='Component' + i + 'onchange ='GetMemos(\Comp + i + \,\ + i + \);'/>< a> + i + < / a>< / ul>);
}
}
function GetMemos(Tagid,data){
if (
( # + Tagid + li)。length == 0 ){
( # + Tagid).addClass(' parent');
for ( var i = 11 跨度>; I< 20;我++){
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function CreateComponents() {
for(var i=0;i<10;i++)
{
$("#TreeView").append("<ul id='Comp" + i + "'><input type='checkbox' id='Component" + i + "' name='Component" +i + "' onchange='GetMemos(\"Comp" + i + "\",\"" + i + "\");' /><a>" + i + "</a></ul>");
}
}
function GetMemos(Tagid, data) {
if ($("#" + Tagid + " li").length == 0) {
$("#" + Tagid).addClass('parent');
for(var i=11;i<20;i++){
$("#" + Tagid + "").append("<li style='padding-removed20px'><input type='checkbox' id='Memo" + i + "' name='Memo" + i + "' /><a>" + i + "</a></li>")
}
}
}
</script>
</head>
<body>
<div id="TreeView" style="width:50%;border:2px solid;height:75%;overflow:hidden;"></div>
<input type="button" value="Create Components" onclick="CreateComponents();" />
</body>
</html>
When i click the Create Component button, i will add some ul and on checkbox of each ul i will add some li.
What i want to do is to make the div size permanent with width 50 % and height 50%.
Can anyone please help me
Thanks in advance
解决方案
("#TreeView").append("<ul id='Comp" + i + "'><input type='checkbox' id='Component" + i + "' name='Component" +i + "' onchange='GetMemos(\"Comp" + i + "\",\"" + i + "\");' /><a>" + i + "</a></ul>"); } } function GetMemos(Tagid, data) { if (
("#" + Tagid + " li").length == 0) {
("#" + Tagid).addClass('parent'); for(var i=11;i<20;i++){
这篇关于使div永久高度&如果内容超出限制,则使其可滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文