簡體   English   中英

帶有自動溢出的錯誤 IE 11

[英]bug IE 11 with overflow auto

當我清空 DIV 中的 html 並使用 JavaScriptS 刪除列表中的類時,IE 11 上存在一個錯誤。 DIV 失去了樣式 CSS "Overflow:auto" 並且守衛是一個很大的高度另一個導航器上沒有錯誤。

樣本:

 <!DOCTYPE html> <html> <head> <title>CSS</title> <style> div { margin: 5px; } ul { margin: 5px; max-height: 200px; overflow: auto; } ul li.selected { font-weight: bold; } .dest { width: 500px; min-height: 21px; max-height: 120px; overflow: auto; border: 1px solid #ccc; background-color: #f9f9f0; padding: 3px; } .dest span { display: block; background-color: #fff; float: left; border-radius: 2px; border: 1px solid #ccc; margin: 2px; padding: 0px 2px 0px 2px; line-height: 21px; height: auto; } </style> <script> window.onload = function(){ document.getElementById("btclear").onclick = function(){ document.getElementById("dest").innerHTML = ""; }; document.getElementById("btclearplus").onclick = function(){ document.getElementById("dest").innerHTML = ""; var ul = document.getElementById("list"); var lis = ul.getElementsByTagName("li"); for (var i = 0; i < lis.length; i++) { lis[i].className = ""; } }; document.getElementById("btall").onclick = function(){ for(var i = 0; i < 50; i++) { var span = document.createElement("span"); span.innerHTML = "first name " + i + " last name " + i; document.getElementById("dest").appendChild(span); } var ul = document.getElementById("list"); var lis = ul.getElementsByTagName("li"); for (var i = 0; i < lis.length; i++) { lis[i].className = "selected"; } }; for(var i = 0; i < 50; i++) { for(var i = 0; i < 50; i++) { var li = document.createElement("li"); li.innerHTML = "nom" + i + " prenom" + i; document.getElementById("list").appendChild(li); } } } </script> </head> <body> <div id="dest" class="dest"></div> <div> <ul id="list"></ul> </div> <div> <button id="btall">Select all</button> <button id="btclear">Clear all</button> <button id="btclearplus">Clear all and deselect</button> </div> </body> </html>

謝謝你,讓-皮埃爾

將循環變量i之一更改為j因為您在兩個循環中都有相同的變量

for(var i = 0; i < 50; i++) {
    for(var j = 0; j < 50; j++) {

         // do you logic
    }       
}

我刪除了雙循環,問題不在這里。 在 Internet Explorer 中,您必須單擊“全選”按鈕,然后單擊“全部清除並取消選擇”按鈕才能重現該問題。

 <!DOCTYPE html> <html> <head> <title>CSS</title> <style> div { margin: 5px; } ul { margin: 5px; max-height: 200px; overflow: auto; } ul li.selected { font-weight: bold; } .dest { width: 500px; min-height: 21px; max-height: 120px; overflow: auto; border: 1px solid #ccc; background-color: #f9f9f0; padding: 3px; } .dest span { display: block; background-color: #fff; float: left; border-radius: 2px; border: 1px solid #ccc; margin: 2px; padding: 0px 2px 0px 2px; line-height: 21px; height: auto; } </style> <script> window.onload = function(){ document.getElementById("btclear").onclick = function(){ document.getElementById("dest").innerHTML = ""; }; document.getElementById("btclearplus").onclick = function(){ document.getElementById("dest").innerHTML = ""; var ul = document.getElementById("list"); var lis = ul.getElementsByTagName("li"); for (var i = 0; i < lis.length; i++) { lis[i].className = ""; } }; document.getElementById("btall").onclick = function(){ for(var i = 0; i < 50; i++) { var span = document.createElement("span"); span.innerHTML = "first name " + i + " last name " + i; document.getElementById("dest").appendChild(span); } var ul = document.getElementById("list"); var lis = ul.getElementsByTagName("li"); for (var i = 0; i < lis.length; i++) { lis[i].className = "selected"; } }; for(var i = 0; i < 50; i++) { var li = document.createElement("li"); li.innerHTML = "nom" + i + " prenom" + i; document.getElementById("list").appendChild(li); } } </script> </head> <body> <div id="dest" class="dest"></div> <div> <ul id="list"></ul> </div> <div> <button id="btall">Select all</button> <button id="btclear">Clear all</button> <button id="btclearplus">Clear all and deselect</button> </div> </body> </html>

謝謝你,讓-皮埃爾

溢出:IE 中的自動問題/錯誤

.element { overflow-y: auto; overflow-x: visible; width: 450px; }

演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM