简体   繁体   English

无法删除垂直元素之间的空间

[英]Can't remove space between vertical elements

I'm trying to code an infinite scrolling monster (like endless.horse but without jQuery). 我正在尝试编写一个无限滚动的怪物(就像endless.horse但没有jQuery)。 But it keeps showing spaces in between elements when scrolling and it doesn't look that good. 但它在滚动时不断显示元素之间的空间,看起来不那么好。 Doing line-height will just smosh the lines together into a weird blob and achieve nothing. 做行高只会将线条一起变成一个奇怪的斑点并且什么都不做。 White space does nothing to stop the spaces. 白色空间无助于阻止空间。 What should I do? 我该怎么办?

 window.onscroll = function() {hello()}; function hello() { var para = document.createElement("pre"); var node = document.createTextNode(` | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `); para.appendChild(node); var element = document.getElementById("hello"); element.appendChild(para); element.appendChild(para); element.appendChild(para); element.appendChild(para); element.appendChild(para); } 
 <html> <head> <title>My first three.js app</title> <script src="myScript.js"></script> <style> body { margin: 0; padding: 0; } #hello float: left; padding: 0; margin: 0; display: inline-block; } pre { padding: 0; margin-bottom: 0; } </style> </head> <body> <pre> _-~~~-_ _-~~~-_ /~ ~\\ : , \\ ' ~ , |: : { /~~\\ :--~""""\\.: : \\ (... : /^\\ /^\\ ; ~\\_____ | | | |:~ / |__O|_|_O|; ( / O \\ \\ ( `\\_______/) `\\ \\ / ) ~-------~'\\ / \\ : || | | || | |.======[]==+'| (~~~~) | |~) / \\ | | \\ ~\\ \\___/)______/^\\__|_/ `\\ // | | | | `\\__//' | | | | ~~ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | </pre> <div id="hello"> </div> </body> </html> 

add got pre{margin:0;} 添加前{margin:0;}

 window.onscroll = function() {hello()}; function hello() { var para = document.createElement("pre"); var node = document.createTextNode(` | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `); para.appendChild(node); var element = document.getElementById("hello"); element.appendChild(para); element.appendChild(para); element.appendChild(para); element.appendChild(para); element.appendChild(para); } 
 pre{margin:0;} 
 <html> <head> <title>My first three.js app</title> <script src="myScript.js"></script> <style> body { margin: 0; padding: 0; } #hello float: left; padding: 0; margin: 0; display: inline-block; } pre { padding: 0; margin-bottom: 0; } </style> </head> <body> <pre> _-~~~-_ _-~~~-_ /~ ~\\ : , \\ ' ~ , |: : { /~~\\ :--~""""\\.: : \\ (... : /^\\ /^\\ ; ~\\_____ | | | |:~ / |__O|_|_O|; ( / O \\ \\ ( `\\_______/) `\\ \\ / ) ~-------~'\\ / \\ : || | | || | |.======[]==+'| (~~~~) | |~) / \\ | | \\ ~\\ \\___/)______/^\\__|_/ `\\ // | | | | `\\__//' | | | | ~~ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | </pre> <div id="hello"> </div> </body> </html> 

重置预保证金。

pre {margin:0}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM