Javascript 将滚动Div调整为浏览器高度
我的滚动div在调整浏览器大小或切换在顶部添加额外空间的按钮时不会拉伸其父容器的高度 8月27日更新 下面的jfiddle包含一个由ctwheels编写的代码,该代码已根据我的需要进行了修改,因此我发现该问题与显示/隐藏按钮过滤器有关(下面提供了代码) 当按下按钮时,此按钮在底部增加一个额外的空间,然后再次按下时消失。但是,这似乎会导致可调整大小的滚动div容器出现问题,该容器应该拉伸到100%的高度和宽度,以填充整个父容器。相反,我总是在底部有一个空格 所以请看一下我的JSFIDLE,看看您是否可以帮助我解决这个问题。谢谢 这里是有问题的HTML:Javascript 将滚动Div调整为浏览器高度,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我的滚动div在调整浏览器大小或切换在顶部添加额外空间的按钮时不会拉伸其父容器的高度 8月27日更新 下面的jfiddle包含一个由ctwheels编写的代码,该代码已根据我的需要进行了修改,因此我发现该问题与显示/隐藏按钮过滤器有关(下面提供了代码) 当按下按钮时,此按钮在底部增加一个额外的空间,然后再次按下时消失。但是,这似乎会导致可调整大小的滚动div容器出现问题,该容器应该拉伸到100%的高度和宽度,以填充整个父容器。相反,我总是在底部有一个空格 所以请看一下我的JSFIDLE,看看您
<div id="feed-content">
<div id="networkfeed" class="feedpagetab activefeed">
<input type="checkbox" id="filterbutton" role="button">
<label for="filterbutton" onclick=""><span class="filterswitch">Show Me</span><span class="filterswitch">Hide Me</span> </label>
<br /><br />
<div class="borderline"></div>
<section class="filtercontent">
</section><!--Filtercontent ends here-->
/*----- Show me Button-----*/
.filtercontent {
margin: 0;border-bottom:#000 solid 1px;
padding: 0; height:170px; margin-top:5px;
-webkit-box-sizing: border-box; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:14px; color:#000;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.feedpagetab > section:first-of-type {
float: right;
width: 62.5%;
}
.feedpagetab > section:last-of-type {
display: none;
visibility: hidden;
}
.feedpagetab {
-webkit-transition: .125s linear;
-moz-transition: .125s linear;
-ms-transition: .125s linear;
-o-transition: .125s linear;
transition: .125s linear;
}
#filterbutton[type=checkbox] {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
}
[for="filterbutton"] {
position: absolute;
top:4px;
padding: 0;
left: 5%;
width: 80px;
text-align: center;
padding: 4px; font-weight:bold;
color: #555;
text-shadow: 1px 1px 1px #DDD;
font-family: Helvetica, Arial, "Sans Serif";
font-size: 13px;
border: 1px solid #CCC;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: inset 0px 0px 1px 0px #FFF;
-moz-box-shadow: inset 0px 0px 1px 0px #FFF;
box-shadow: inset 0px 0px 1px 0px #FFF;
background: #EEE;
background: -moz-linear-gradient(top, #F9F9F9 0%, #DDD 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F9F9F9), color-stop(100%,#DDD));
background: -webkit-linear-gradient(top, #F9F9F9 0%,#DDD 100%);
background: -o-linear-gradient(top, #F9F9F9 0%,#DDD 100%);
background: -ms-linear-gradient(top, #F9F9F9 0%,#DDD 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F9F9F9', endColorstr='#DDD',GradientType=0 );
background: linear-gradient(top, #F9F9F9 0%,#DDD 100%);
}
[for="filterbutton"]:hover {
color: #444444;font-weight:bold;
border-color: #BBB;
background: #CCC;
background: -moz-linear-gradient(top, #F9F9F9 0%, #CCC 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F9F9F9), color-stop(100%,#CCC));
background: -webkit-linear-gradient(top, #F9F9F9 0%,#CCC 100%);
background: -o-linear-gradient(top, #F9F9F9 0%,#CCC 100%);
background: -ms-linear-gradient(top, #F9F9F9 0%,#CCC 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F9F9F9', endColorstr='#CCC',GradientType=0 );
}
[for="filterbutton"] span.filterswitch:last-of-type {
display: none;
visibility: hidden;
}
#filterbutton[type=checkbox]:checked {color:#FFA317;}
#filterbutton[type=checkbox]:checked ~ .filtercontent {
display: block;
visibility: visible;
width: 100%;
}
#filterbutton[type=checkbox]:checked ~ [for="filterbutton"] span.filterswitch:first-of-type {
display: none;
visibility: hidden;
}
#filterbutton[type=checkbox]:checked ~ [for="filterbutton"] span.filterswitch:last-of-type { color:#3CC;
display: block;
visibility: visible;
}
.borderline { width:100%; border-bottom:#000 solid 1px; height:0px;}
.filtercontent { margin-left:29%; }
你为什么对自己这么苛刻。。。如果html有错误,你会有很多错误。为什么布局不这样呢?您提供的JSFIDLE不包含一个带有滚动条的div,它填充整个父容器,并根据浏览器或切换内容调整大小。你能把它加到你的小提琴上吗。我只想掌握它的概念和背后的代码。另外,我的代码也有一些错误,但错误不足以阻止滚动流体div正常工作。这里:父div没有覆盖整个可用空间,带有滚动条的div没有根据浏览器的高度调整大小。那么你能把它加到小提琴上吗?这里:它并不完美,但它完成了任务。