[英]Why doesn't overflow work in my document?
我的問題...
由於某種原因,我使用CSS overflow: auto
制作的滾輪overflow: auto
停止工作,為什么? 滾輪是必需的,因為這是一個較長的側欄,應該有自己的滾輪
注意:我刪除了很多li和ul,以便發布問題
就像您在我的代碼中看到的那樣,還有很多重復的ul和li。 有沒有更簡單的方法來編寫所有這些內容?
我的代碼...
<body>
<div id="mainBar" class="mainBarOthers">
<ul>
<a href="EverythingPrg.html">
<li class="theTitle">
Home Page
</li>
</a>
</ul>
<ul class="ulHighlight">
<a href="Added Arrays.html" >
<li>
Added Arrays
</li>
</a>
</ul>
<ul>
<a href="AddOrMinus.html">
<li>
AddOrMinus
</li>
</a>
</ul>
<ul>
<a href="ArayOnlyNumbers.html">
<li>
ArayOnlyNumbers
</li>
</a>
</ul>
<ul>
<a href="Array Drawing.html">
<li>
Array Drawing
</li>
</a>
</ul>
<ul>
<a href="Array Squared.html">
<li>
Array Squared
</li>
</a>
</ul>
我的CSS ...
.mainBarOthers {width: 18%; border-right: 2px solid black; background-color: #feffdd; float: left; overflow: auto; box-shadow: 0px 1px 10px black; -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ -khtml-user-select: none; /* Konqueror HTML */-moz-user-select: none; /* Firefox */ -ms-user-select: none; /* Internet Explorer/Edge */ user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */}
還有我的JavaScript ...
window.onload = function () {
setInterval (function () {
height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight);
if (height != heightCheck) {
height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight);
height = height - 52;
heightCheck = height;
document.getElementById ('mainBar').style.cssText = 'height:' + height;}
}, 10); // This makes the main bar be the size of the page (can this slow the page down? Better way of doing it...)
}
回答...
var height;
var heightOthers;
var heightCheck;
var heightCheckOthers;
window.onload = function () {
setInterval (function () {
height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight);
heightOthers = Math.max (document.body.scrollHeight, document.documentElement.clientHeight);
$(function () {
if ($('#mainBarOthers').length) {
if (heightOthers != heightCheckOthers) {
heightOthers = Math.max(document.body.scrollHeight, document.documentElement.clientHeight);
heightCheckOthers = heightOthers;
document.getElementById ('mainBarOthers').style.cssText = 'height:' + heightOthers;
}
}
else if ($('#mainBar').length) {
if (height != heightCheck) {
height = Math.max (document.body.scrollHeight, document.documentElement.clientHeight);
height = height - 52;
heightCheck = height;
document.getElementById ('mainBar').style.cssText = 'height:' + height;
}
}
});
}, 10); // This makes the main bar be the size of the page (can this slow the page down? Better way of doing it...)
}
問題是我有兩個不同的頁面,並且id是相同的,所以他們互相寫了信。 解決方法是簡單地為其他第二頁的高度設置相同的功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.