简体   繁体   English

HTML中的DIV动态更改,但添加空白

[英]DIV in HTML dynamically changing but add white space

I have been working on a dynamic question thingee(technical terms) but of course there is always some small hop that you need to overcome. 我一直在研究动态问题(技术术语),但是当然总有一些小问题需要克服。 My issue is that when I select 'show answer' on one of the question panels then the dividers add a massive white space between the rows. 我的问题是,当我在一个问题面板上选择“显示答案”时,分隔线会在行之间添加大量空白。 Basically the amount of questions asked are managed by the width of the screen, then via AJAX is gets the questions from index.php?questions&a={insertwidthofscreen*4} this is done via javascript and works automatically. 基本上,问题的数量是由屏幕的宽度来管理的,然后通过AJAX从index.php?questions&a={insertwidthofscreen*4}获取问题,这是通过javascript完成的,并且可以自动运行。

The code that I have is the following, it is called 'math.php' as a temp test: http://pastebin.com/MjGgSTYh Everything is generated via the above file and no external connections are made, the database stuff is easy and I will use my old system that keeps a track of what has already been shown. 我拥有的代码如下,它被称为“ math.php”作为临时测试: http ://pastebin.com/MjGgSTYh一切都是通过上述文件生成的,没有进行外部连接,数据库的工作很容易并且我将使用旧系统来跟踪已显示的内容。

The idea is that all the DIVS change height when the answer button is clicked, the height is dependent on the answer, the answer could vary from 1 word to a paragraph. 这个想法是,当单击答案按钮时,所有DIVS都会改变高度,高度取决于答案,答案可能从1个单词到一个段落不等。

Screen shots of what I mean with the white space. 我对空白的意思的屏幕截图。 http://imgur.com/KAOPHFI,wj0vWSg there is two photos in that, I didn't see the next button for a while. http://imgur.com/KAOPHFI,wj0vWSg里面有两张照片,我好一阵子没看到下一个按钮了。

Cheers, Leon 干杯,莱昂

Since it isn't complete code (and therefore difficult for me to test myself) I'll just spitball this -- your qbox style (and possibly others?) have fixed width -- qbox is 200px. 由于它不是完整的代码(因此我很难测试自己),因此我将对此加以说明-您的qbox样式(可能还有其他样式?)具有固定的宽度-qbox为200px。 Should that be dynamic? 那应该是动态的吗? (you also have width listed twice, but same value so it shouldn't matter in this case) (您也列出了两次宽度,但是值相同,所以在这种情况下没关系)

If you want to post more complete code that I can paste into a file myself, I'd be able to troubleshoot much easier. 如果您想发布更完整的代码以供我自己粘贴到文件中,则可以更轻松地进行故障排除。

Update: 更新:

I see what is happening now. 我知道现在发生了什么。 The whitespace occurs when you click the answers in a particular order -- ie if you go through them left to right top to bottom, there is no extra whitespace, but if you click diagonally like in your screencap, the whitespace is added to allow for the length of the current answer, but doesn't reorder the previous cells to utilize the space. 当您按特定的顺序单击答案时,会出现空白-即,如果您从左到右从上到下浏览它们,则不会有多余的空格,但是如果您像在屏幕截图中那样沿对角线单击,则会添加空格以允许当前答案的长度,但不会重新排序先前的单元以利用空间。

In order to resolve this, it looks like you'll have to relocate some of the answer boxes when one answer is clicked on... just expanding them in a certain order will cause the issue you're seeing. 为了解决这个问题,当您单击一个答案时,您似乎必须重新放置一些答案框...仅按特定顺序扩展它们会引起您所遇到的问题。 Another option would be to have an answer pane/frame, on the side or bottom of the page, that shows the answer without expanding the question boxes themselves. 另一种选择是在页面的侧面或底部有一个答案窗格/框架,该答案窗格/框架显示答案而无需扩展问题框本身。 I can't picture the algorithm you'd need to auto rearrange the boxes every time one is clicked... 我无法想象每次单击框时都需要自动重新排列框的算法...

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

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