当body设置为DIV
时,我如何启用内部overflow:hidden
上的滚动,因为我有限制编辑正文CSS
Body CSS
body {
margin: 0;
padding: 0;
background-color: #000;
overflow: hidden;
max-width: 100%;
max-height: 100%;
}
内部DIV css跟随 - 默认情况下,div的高度由jQuery设置。
.custom-gallery-lineage {
float: left;
width: 100%;
overflow: auto;
color: #fff;
font-size: 18px;
}
答案 0 :(得分:4)
而不是 <span class="additional-background ms-navedit-flyoutArrow">
<span class="menu-item-text">AIRS</span>
</span>
</a>
<ul class="static">
<li class="static">
alert(subListToShow.closest('span .menu-item-text').text());
您必须使用$(document).height()
,请检查以下代码段或更新的小提琴https://jsfiddle.net/sgh1gqh5/2/
$(window).height()
$(document).ready(function() {
var winw = $(window).width();
var winh = $(window).height();
$(".custom-gallery-lineage").height(winh);
});
body {
margin: 0;
padding: 0;
background-color: #000;
overflow: hidden;
max-width: 100%;
max-height: 100%;
}
.custom-gallery-lineage {
float: left;
width: 100%;
overflow: auto;
color: #fff;
font-size: 18px;
}
答案 1 :(得分:2)
问题是因为您要将元素的height
设置为与document
匹配。相反,请使用window
:
$(document).ready(function() {
var winw = $(window).width();
var winh = $(window).height();
$(".custom-gallery-lineage").height(winh);
});
更好的是,根本不使用JS,并使用CSS中的vh
单位设置高度:
body {
margin: 0;
padding: 0;
background-color: #000;
overflow: hidden;
max-width: 100%;
max-height: 100%;
}
.custom-gallery-lineage {
float: left;
width: 100%;
overflow: auto;
color: #fff;
font-size: 18px;
height: 100vh;
}
&#13;
<div class="custom-gallery-lineage">
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
<p>This is test content</p>
</div>
&#13;
答案 2 :(得分:0)
试试这个
$(document).ready(function() {
var winw = $(document).width();
var winh = $(window).height();
$(".custom-gallery-lineage").height(winh);
});
&#13;